aboutsummaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit/src/org/eclipse/jgit/api/CherryPickCommand.java
diff options
context:
space:
mode:
authorMatthias Sohn <matthias.sohn@sap.com>2020-04-27 15:14:52 +0200
committerMatthias Sohn <matthias.sohn@sap.com>2020-04-28 08:48:14 +0200
commit7ae35079981dbacecb033fc1980d7d4e16b59fdc (patch)
tree48f04f5fe30f72dac5ee0cc5fd609c0cd4b556c7 /org.eclipse.jgit/src/org/eclipse/jgit/api/CherryPickCommand.java
parent560ef875e399cc20c3fce4a119c6ed2118fbe62d (diff)
downloadjgit-7ae35079981dbacecb033fc1980d7d4e16b59fdc.tar.gz
jgit-7ae35079981dbacecb033fc1980d7d4e16b59fdc.zip
CherryPickCommand: fix unclosed resource warning
Change-Id: I2dc76efd16d887048a5cb4af2b2d8e6faa4f22cd Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
Diffstat (limited to 'org.eclipse.jgit/src/org/eclipse/jgit/api/CherryPickCommand.java')
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/api/CherryPickCommand.java14
1 files changed, 8 insertions, 6 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/api/CherryPickCommand.java b/org.eclipse.jgit/src/org/eclipse/jgit/api/CherryPickCommand.java
index c5bc8587ef..5d0154c6dc 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/api/CherryPickCommand.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/api/CherryPickCommand.java
@@ -142,12 +142,14 @@ public class CherryPickCommand extends GitCommand<CherryPickResult> {
dco.setProgressMonitor(monitor);
dco.checkout();
if (!noCommit) {
- newHead = new Git(getRepository()).commit()
- .setMessage(srcCommit.getFullMessage())
- .setReflogComment(reflogPrefix + " " //$NON-NLS-1$
- + srcCommit.getShortMessage())
- .setAuthor(srcCommit.getAuthorIdent())
- .setNoVerify(true).call();
+ try (Git git = new Git(getRepository())) {
+ newHead = git.commit()
+ .setMessage(srcCommit.getFullMessage())
+ .setReflogComment(reflogPrefix + " " //$NON-NLS-1$
+ + srcCommit.getShortMessage())
+ .setAuthor(srcCommit.getAuthorIdent())
+ .setNoVerify(true).call();
+ }
}
cherryPickedRefs.add(src);
} else {