* @throws JGitInternalException
* upon internal failure
*/
public Note call() throws JGitInternalException {
checkCallable();
RevWalk walk = new RevWalk(repo);
ObjectInserter inserter = repo.newObjectInserter();
NoteMap map = NoteMap.newEmptyMap();
RevCommit notesCommit = null;
try {
Ref ref = repo.getRef(notesRef);
// if we have a notes ref, use it
if (ref != null) {
notesCommit = walk.parseCommit(ref.getObjectId());
map = NoteMap.read(walk.getObjectReader(), notesCommit);
}
map.set(id, message, inserter);
commitNoteMap(walk, map, notesCommit, inserter,
"Notes added by 'git notes add'");
return map.getNote(id);
} catch (IOException e) {
throw new JGitInternalException(e.getMessage(), e);
} finally {
inserter.release();
walk.release();
}
}