|
|
@ -83,11 +83,10 @@ public class AddNoteCommand extends GitCommand<Note> { |
|
|
|
|
|
|
|
|
|
|
|
public Note call() throws GitAPIException { |
|
|
|
public Note call() throws GitAPIException { |
|
|
|
checkCallable(); |
|
|
|
checkCallable(); |
|
|
|
RevWalk walk = new RevWalk(repo); |
|
|
|
|
|
|
|
ObjectInserter inserter = repo.newObjectInserter(); |
|
|
|
|
|
|
|
NoteMap map = NoteMap.newEmptyMap(); |
|
|
|
NoteMap map = NoteMap.newEmptyMap(); |
|
|
|
RevCommit notesCommit = null; |
|
|
|
RevCommit notesCommit = null; |
|
|
|
try { |
|
|
|
try (RevWalk walk = new RevWalk(repo); |
|
|
|
|
|
|
|
ObjectInserter inserter = repo.newObjectInserter()) { |
|
|
|
Ref ref = repo.getRef(notesRef); |
|
|
|
Ref ref = repo.getRef(notesRef); |
|
|
|
// if we have a notes ref, use it
|
|
|
|
// if we have a notes ref, use it
|
|
|
|
if (ref != null) { |
|
|
|
if (ref != null) { |
|
|
@ -96,13 +95,10 @@ public class AddNoteCommand extends GitCommand<Note> { |
|
|
|
} |
|
|
|
} |
|
|
|
map.set(id, message, inserter); |
|
|
|
map.set(id, message, inserter); |
|
|
|
commitNoteMap(walk, map, notesCommit, inserter, |
|
|
|
commitNoteMap(walk, map, notesCommit, inserter, |
|
|
|
"Notes added by 'git notes add'"); |
|
|
|
"Notes added by 'git notes add'"); //$NON-NLS-1$
|
|
|
|
return map.getNote(id); |
|
|
|
return map.getNote(id); |
|
|
|
} catch (IOException e) { |
|
|
|
} catch (IOException e) { |
|
|
|
throw new JGitInternalException(e.getMessage(), e); |
|
|
|
throw new JGitInternalException(e.getMessage(), e); |
|
|
|
} finally { |
|
|
|
|
|
|
|
inserter.release(); |
|
|
|
|
|
|
|
walk.release(); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|