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) {
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());
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