Browse Source

CherryPickCommand: fix unclosed resource warning

Change-Id: I2dc76efd16d887048a5cb4af2b2d8e6faa4f22cd
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
stable-5.8
Matthias Sohn 5 years ago
parent
commit
7ae3507998
  1. 14
      org.eclipse.jgit/src/org/eclipse/jgit/api/CherryPickCommand.java

14
org.eclipse.jgit/src/org/eclipse/jgit/api/CherryPickCommand.java

@ -142,12 +142,14 @@ public class CherryPickCommand extends GitCommand<CherryPickResult> {
dco.setProgressMonitor(monitor); dco.setProgressMonitor(monitor);
dco.checkout(); dco.checkout();
if (!noCommit) { if (!noCommit) {
newHead = new Git(getRepository()).commit() try (Git git = new Git(getRepository())) {
.setMessage(srcCommit.getFullMessage()) newHead = git.commit()
.setReflogComment(reflogPrefix + " " //$NON-NLS-1$ .setMessage(srcCommit.getFullMessage())
+ srcCommit.getShortMessage()) .setReflogComment(reflogPrefix + " " //$NON-NLS-1$
.setAuthor(srcCommit.getAuthorIdent()) + srcCommit.getShortMessage())
.setNoVerify(true).call(); .setAuthor(srcCommit.getAuthorIdent())
.setNoVerify(true).call();
}
} }
cherryPickedRefs.add(src); cherryPickedRefs.add(src);
} else { } else {

Loading…
Cancel
Save