summaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit
diff options
context:
space:
mode:
authorBernard Leach <leachbj@bouncycastle.org>2011-05-23 00:20:32 +1000
committerChris Aniszczyk <caniszczyk@gmail.com>2011-05-23 08:24:30 -0500
commitcf846cfb0b2ceb65749561a0ea1cbbc0904a2ee9 (patch)
tree28221210aa51fd3b27953ca1af86a53fca0cc554 /org.eclipse.jgit
parent40fa75feb4536218a59b4cb6ea71e3579c8000dd (diff)
downloadjgit-cf846cfb0b2ceb65749561a0ea1cbbc0904a2ee9.tar.gz
jgit-cf846cfb0b2ceb65749561a0ea1cbbc0904a2ee9.zip
Remove rebase temporary files on checkout failure
A checkout conflict during rebase setup should leave the repository in SAFE state which means ensuring that the rebase temporary files need to be removed. Bug: 346813 Change-Id: If8b758fde73ed5a452a99a195a844825a03bae1a Signed-off-by: Chris Aniszczyk <caniszczyk@gmail.com>
Diffstat (limited to 'org.eclipse.jgit')
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/api/RebaseCommand.java11
1 files changed, 9 insertions, 2 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 114ef03a3b..1503857ca3 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/api/RebaseCommand.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/api/RebaseCommand.java
@@ -595,7 +595,13 @@ public class RebaseCommand extends GitCommand<RebaseResult> {
// we rewind to the upstream commit
monitor.beginTask(MessageFormat.format(JGitText.get().rewinding,
upstreamCommit.getShortMessage()), ProgressMonitor.UNKNOWN);
- checkoutCommit(upstreamCommit);
+ boolean checkoutOk = false;
+ try {
+ checkoutOk = checkoutCommit(upstreamCommit);
+ } finally {
+ if (!checkoutOk)
+ FileUtils.delete(rebaseDir, FileUtils.RECURSIVE);
+ }
monitor.endTask();
return null;
@@ -771,7 +777,7 @@ public class RebaseCommand extends GitCommand<RebaseResult> {
return RawParseUtils.decode(content, 0, end);
}
- private void checkoutCommit(RevCommit commit) throws IOException {
+ private boolean checkoutCommit(RevCommit commit) throws IOException {
try {
RevCommit head = walk.parseCommit(repo.resolve(Constants.HEAD));
DirCacheCheckout dco = new DirCacheCheckout(repo, head.getTree(),
@@ -795,6 +801,7 @@ public class RebaseCommand extends GitCommand<RebaseResult> {
walk.release();
monitor.endTask();
}
+ return true;
}
private List<Step> loadSteps() throws IOException {