diff options
author | Stefan Lay <stefan.lay@sap.com> | 2014-01-15 13:23:49 +0100 |
---|---|---|
committer | Stefan Lay <stefan.lay@sap.com> | 2014-01-15 13:23:49 +0100 |
commit | 3db6e05e52b24e16fbe93376d3fd8935e5f4fc9b (patch) | |
tree | 4a9f8e99245580948d62be7077f389156809e671 | |
parent | 50a830f7d477e7e04eaf95f5e8af88fc308bcecd (diff) | |
download | jgit-3db6e05e52b24e16fbe93376d3fd8935e5f4fc9b.tar.gz jgit-3db6e05e52b24e16fbe93376d3fd8935e5f4fc9b.zip |
Fix fast forward rebase with rebase.autostash=true
The folder .git/rebase-merge was not removed in this case. The
repository was then still in rebase state, but neither abort nor
continue worked.
Bug: 425742
Change-Id: I43cea6c9e5f3cef9d6b15643722fddecb40632d9
-rw-r--r-- | org.eclipse.jgit.test/tst/org/eclipse/jgit/api/RebaseCommandTest.java | 39 | ||||
-rw-r--r-- | org.eclipse.jgit/src/org/eclipse/jgit/api/RebaseCommand.java | 3 |
2 files changed, 42 insertions, 0 deletions
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/RebaseCommandTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/RebaseCommandTest.java index a728cd2461..40eb494045 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/RebaseCommandTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/RebaseCommandTest.java @@ -1737,6 +1737,45 @@ public class RebaseCommandTest extends RepositoryTestCase { assertEquals("file1", diffs.get(0).getOldPath()); } + @Test + public void testFastForwardRebaseWithAutoStash() throws Exception { + // create file0, add and commit + db.getConfig().setBoolean(ConfigConstants.CONFIG_REBASE_SECTION, null, + ConfigConstants.CONFIG_KEY_AUTOSTASH, true); + writeTrashFile("file0", "file0"); + git.add().addFilepattern("file0").call(); + git.commit().setMessage("commit0").call(); + // create file1, add and commit + writeTrashFile(FILE1, "file1"); + git.add().addFilepattern(FILE1).call(); + RevCommit commit = git.commit().setMessage("commit1").call(); + + // create topic branch + createBranch(commit, "refs/heads/topic"); + + // checkout master branch / modify file1, add and commit + checkoutBranch("refs/heads/master"); + writeTrashFile(FILE1, "modified file1"); + git.add().addFilepattern(FILE1).call(); + git.commit().setMessage("commit3").call(); + + // checkout topic branch / modify file0 + checkoutBranch("refs/heads/topic"); + writeTrashFile("file0", "unstaged modified file0"); + + // rebase + assertEquals(Status.FAST_FORWARD, + git.rebase().setUpstream("refs/heads/master") + .call().getStatus()); + checkFile(new File(db.getWorkTree(), "file0"), + "unstaged modified file0"); + checkFile(new File(db.getWorkTree(), FILE1), "modified file1"); + assertEquals("[file0, mode:100644, content:file0]" + + "[file1, mode:100644, content:modified file1]", + indexState(CONTENT)); + assertEquals(RepositoryState.SAFE, db.getRepositoryState()); + } + private List<DiffEntry> getStashedDiff() throws AmbiguousObjectException, IncorrectObjectTypeException, IOException, MissingObjectException { ObjectId stashId = db.resolve("stash@{0}"); 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 ac6f5487a1..e930c535e6 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/api/RebaseCommand.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/api/RebaseCommand.java @@ -281,6 +281,9 @@ public class RebaseCommand extends GitCommand<RebaseResult> { return RebaseResult.INTERACTIVE_PREPARED_RESULT; if (res != null) { autoStashApply(); + if (rebaseState.getDir().exists()) + FileUtils.delete(rebaseState.getDir(), + FileUtils.RECURSIVE); return res; } } |