Browse Source

MergeCommand: Open RevWalk in try-with-resource

Change-Id: I45ce481cc198b8dc78e9c46b433504840597e982
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
stable-4.11
David Pursehouse 7 years ago
parent
commit
2c29af7867
  1. 7
      org.eclipse.jgit/src/org/eclipse/jgit/api/MergeCommand.java

7
org.eclipse.jgit/src/org/eclipse/jgit/api/MergeCommand.java

@ -237,9 +237,8 @@ public class MergeCommand extends GitCommand<MergeResult> {
fallBackToConfiguration(); fallBackToConfiguration();
checkParameters(); checkParameters();
RevWalk revWalk = null;
DirCacheCheckout dco = null; DirCacheCheckout dco = null;
try { try (RevWalk revWalk = new RevWalk(repo)) {
Ref head = repo.exactRef(Constants.HEAD); Ref head = repo.exactRef(Constants.HEAD);
if (head == null) if (head == null)
throw new NoHeadException( throw new NoHeadException(
@ -247,7 +246,6 @@ public class MergeCommand extends GitCommand<MergeResult> {
StringBuilder refLogMessage = new StringBuilder("merge "); //$NON-NLS-1$ StringBuilder refLogMessage = new StringBuilder("merge "); //$NON-NLS-1$
// Check for FAST_FORWARD, ALREADY_UP_TO_DATE // Check for FAST_FORWARD, ALREADY_UP_TO_DATE
revWalk = new RevWalk(repo);
// we know for now there is only one commit // we know for now there is only one commit
Ref ref = commits.get(0); Ref ref = commits.get(0);
@ -439,9 +437,6 @@ public class MergeCommand extends GitCommand<MergeResult> {
MessageFormat.format( MessageFormat.format(
JGitText.get().exceptionCaughtDuringExecutionOfMergeCommand, JGitText.get().exceptionCaughtDuringExecutionOfMergeCommand,
e), e); e), e);
} finally {
if (revWalk != null)
revWalk.close();
} }
} }

Loading…
Cancel
Save