summaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit
diff options
context:
space:
mode:
authorMatthias Sohn <matthias.sohn@sap.com>2016-12-18 01:24:56 +0100
committerMatthias Sohn <matthias.sohn@sap.com>2016-12-18 10:38:24 +0100
commit82344bd7a234de3cb7fd3358d2ba355adb484181 (patch)
tree2138ec2cff1d97893755a2ae766131742541bad7 /org.eclipse.jgit
parent05e8cdf5634f3c8392235eb34d16df208777311f (diff)
downloadjgit-82344bd7a234de3cb7fd3358d2ba355adb484181.tar.gz
jgit-82344bd7a234de3cb7fd3358d2ba355adb484181.zip
[infer] Fix resource leaks in RebaseCommand
Bug: 509385 Change-Id: I9fbdfda59f7bc577aab55dc92ff897b00b5cb050 Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
Diffstat (limited to 'org.eclipse.jgit')
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/api/RebaseCommand.java16
1 files changed, 9 insertions, 7 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/api/RebaseCommand.java b/org.eclipse.jgit/src/org/eclipse/jgit/api/RebaseCommand.java
index c5c0cfb821..d10cc3d715 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/api/RebaseCommand.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/api/RebaseCommand.java
@@ -400,8 +400,8 @@ public class RebaseCommand extends GitCommand<RebaseResult> {
boolean conflicts = false;
if (rebaseState.getFile(AUTOSTASH).exists()) {
String stash = rebaseState.readFile(AUTOSTASH);
- try {
- Git.wrap(repo).stashApply().setStashRef(stash)
+ try (Git git = Git.wrap(repo)) {
+ git.stashApply().setStashRef(stash)
.ignoreRepositoryState(true).setStrategy(strategy)
.call();
} catch (StashApplyFailureException e) {
@@ -463,8 +463,10 @@ public class RebaseCommand extends GitCommand<RebaseResult> {
String oldMessage = commitToPick.getFullMessage();
String newMessage = interactiveHandler
.modifyCommitMessage(oldMessage);
- newHead = new Git(repo).commit().setMessage(newMessage)
- .setAmend(true).setNoVerify(true).call();
+ try (Git git = new Git(repo)) {
+ newHead = git.commit().setMessage(newMessage).setAmend(true)
+ .setNoVerify(true).call();
+ }
return null;
case EDIT:
rebaseState.createFile(AMEND, commitToPick.name());
@@ -753,12 +755,12 @@ public class RebaseCommand extends GitCommand<RebaseResult> {
GitAPIException, CheckoutConflictException {
Ref ref = repo.exactRef(Constants.ORIG_HEAD);
ObjectId orig_head = ref == null ? null : ref.getObjectId();
- try {
- // we have already commited the cherry-picked commit.
+ try (Git git = Git.wrap(repo)) {
+ // we have already committed the cherry-picked commit.
// what we need is to have changes introduced by this
// commit to be on the index
// resetting is a workaround
- Git.wrap(repo).reset().setMode(ResetType.SOFT)
+ git.reset().setMode(ResetType.SOFT)
.setRef("HEAD~1").call(); //$NON-NLS-1$
} finally {
// set ORIG_HEAD back to where we started because soft