summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Pursehouse <david.pursehouse@gmail.com>2018-03-07 14:46:08 +0900
committerDavid Pursehouse <david.pursehouse@gmail.com>2018-03-07 14:46:08 +0900
commit2c29af786763c0c8d74741c86edbeff4e5140e35 (patch)
treefe4b4519d0f260add265e33dd0c9bf2b4a0943af
parent057a295f0c88613d1a8d45e07be07e2d59c21150 (diff)
downloadjgit-2c29af786763c0c8d74741c86edbeff4e5140e35.tar.gz
jgit-2c29af786763c0c8d74741c86edbeff4e5140e35.zip
MergeCommand: Open RevWalk in try-with-resource
Change-Id: I45ce481cc198b8dc78e9c46b433504840597e982 Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/api/MergeCommand.java7
1 files changed, 1 insertions, 6 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/api/MergeCommand.java b/org.eclipse.jgit/src/org/eclipse/jgit/api/MergeCommand.java
index 2eced1e700..cd50cae4fb 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/api/MergeCommand.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/api/MergeCommand.java
@@ -237,9 +237,8 @@ public class MergeCommand extends GitCommand<MergeResult> {
fallBackToConfiguration();
checkParameters();
- RevWalk revWalk = null;
DirCacheCheckout dco = null;
- try {
+ try (RevWalk revWalk = new RevWalk(repo)) {
Ref head = repo.exactRef(Constants.HEAD);
if (head == null)
throw new NoHeadException(
@@ -247,7 +246,6 @@ public class MergeCommand extends GitCommand<MergeResult> {
StringBuilder refLogMessage = new StringBuilder("merge "); //$NON-NLS-1$
// Check for FAST_FORWARD, ALREADY_UP_TO_DATE
- revWalk = new RevWalk(repo);
// we know for now there is only one commit
Ref ref = commits.get(0);
@@ -439,9 +437,6 @@ public class MergeCommand extends GitCommand<MergeResult> {
MessageFormat.format(
JGitText.get().exceptionCaughtDuringExecutionOfMergeCommand,
e), e);
- } finally {
- if (revWalk != null)
- revWalk.close();
}
}