Merge changes Iad4d4127,I0211bcf0

* changes:
  Silence warning for non-translatable String in AddNoteCommand
  Use try-with-resources to fix warnings in AddNoteCommand
This commit is contained in:
Shawn Pearce 2015-04-08 21:07:05 -04:00 committed by Gerrit Code Review @ Eclipse.org
commit 481405f770
1 changed files with 3 additions and 7 deletions

View File

@ -83,11 +83,10 @@ protected AddNoteCommand(Repository repo) {
public Note call() throws GitAPIException {
checkCallable();
RevWalk walk = new RevWalk(repo);
ObjectInserter inserter = repo.newObjectInserter();
NoteMap map = NoteMap.newEmptyMap();
RevCommit notesCommit = null;
try {
try (RevWalk walk = new RevWalk(repo);
ObjectInserter inserter = repo.newObjectInserter()) {
Ref ref = repo.getRef(notesRef);
// if we have a notes ref, use it
if (ref != null) {
@ -96,13 +95,10 @@ public Note call() throws GitAPIException {
}
map.set(id, message, 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);
} catch (IOException e) {
throw new JGitInternalException(e.getMessage(), e);
} finally {
inserter.release();
walk.release();
}
}