From 2c29af786763c0c8d74741c86edbeff4e5140e35 Mon Sep 17 00:00:00 2001 From: David Pursehouse Date: Wed, 7 Mar 2018 14:46:08 +0900 Subject: [PATCH] MergeCommand: Open RevWalk in try-with-resource Change-Id: I45ce481cc198b8dc78e9c46b433504840597e982 Signed-off-by: David Pursehouse --- .../src/org/eclipse/jgit/api/MergeCommand.java | 7 +------ 1 file changed, 1 insertion(+), 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 { 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 { 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 { MessageFormat.format( JGitText.get().exceptionCaughtDuringExecutionOfMergeCommand, e), e); - } finally { - if (revWalk != null) - revWalk.close(); } } -- 2.39.5