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. 4
      org.eclipse.jgit/src/org/eclipse/jgit/api/CherryPickCommand.java

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

@ -142,13 +142,15 @@ 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())) {
newHead = git.commit()
.setMessage(srcCommit.getFullMessage()) .setMessage(srcCommit.getFullMessage())
.setReflogComment(reflogPrefix + " " //$NON-NLS-1$ .setReflogComment(reflogPrefix + " " //$NON-NLS-1$
+ srcCommit.getShortMessage()) + srcCommit.getShortMessage())
.setAuthor(srcCommit.getAuthorIdent()) .setAuthor(srcCommit.getAuthorIdent())
.setNoVerify(true).call(); .setNoVerify(true).call();
} }
}
cherryPickedRefs.add(src); cherryPickedRefs.add(src);
} else { } else {
if (merger.failed()) { if (merger.failed()) {

Loading…
Cancel
Save