summaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit.test
diff options
context:
space:
mode:
authorShawn Pearce <spearce@spearce.org>2011-05-23 11:33:49 -0400
committerCode Review <codereview-daemon@eclipse.org>2011-05-23 11:33:49 -0400
commitc25c60061d43b521a428301960120794b9fba4f2 (patch)
treee3bddf1d2ff8e590cb32481abf566c1c5752036f /org.eclipse.jgit.test
parent3344b93c84fa351623bf686d71dff9769e87144b (diff)
parentcf846cfb0b2ceb65749561a0ea1cbbc0904a2ee9 (diff)
downloadjgit-c25c60061d43b521a428301960120794b9fba4f2.tar.gz
jgit-c25c60061d43b521a428301960120794b9fba4f2.zip
Merge "Remove rebase temporary files on checkout failure"
Diffstat (limited to 'org.eclipse.jgit.test')
-rw-r--r--org.eclipse.jgit.test/tst/org/eclipse/jgit/api/RebaseCommandTest.java41
1 files changed, 39 insertions, 2 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 9197ac9983..672f4d86aa 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
@@ -164,7 +164,7 @@ public class RebaseCommandTest extends RepositoryTestCase {
* Create the following commits and then attempt to rebase topic onto
* master. This will fail as the cherry-pick list C, D, E an F contains
* a merge commit (F).
- *
+ *
* <pre>
* A - B (master)
* \
@@ -1053,7 +1053,7 @@ public class RebaseCommandTest extends RepositoryTestCase {
// checkout topic branch / modify file2 and add
checkoutBranch("refs/heads/topic");
- writeTrashFile("file2", "uncommitted file2");
+ File uncommittedFile = writeTrashFile("file2", "uncommitted file2");
git.add().addFilepattern("file2").call();
// do not commit
@@ -1067,6 +1067,9 @@ public class RebaseCommandTest extends RepositoryTestCase {
assertNotNull(exception);
assertEquals("Checkout conflict with files: \nfile2",
exception.getMessage());
+
+ checkFile(uncommittedFile, "uncommitted file2");
+ assertEquals(RepositoryState.SAFE, git.getRepository().getRepositoryState());
}
@Test
@@ -1375,4 +1378,38 @@ public class RebaseCommandTest extends RepositoryTestCase {
checkFile(new File(db.getWorkTree(), "file2"), "more change");
assertEquals(Status.FAST_FORWARD, res.getStatus());
}
+
+ @Test
+ public void testRebaseShouldLeaveWorkspaceUntouchedWithUnstagedChangesConflict()
+ throws Exception {
+ writeTrashFile(FILE1, "initial file");
+ git.add().addFilepattern(FILE1).call();
+ RevCommit initial = git.commit().setMessage("initial commit").call();
+ createBranch(initial, "refs/heads/side");
+
+ writeTrashFile(FILE1, "updated file");
+ git.add().addFilepattern(FILE1).call();
+ git.commit().setMessage("updated FILE1 on master").call();
+
+ // switch to side, modify the file
+ checkoutBranch("refs/heads/side");
+ writeTrashFile(FILE1, "side update");
+ git.add().addFilepattern(FILE1).call();
+ git.commit().setMessage("updated FILE1 on side").call();
+
+ File theFile = writeTrashFile(FILE1, "dirty the file");
+
+ // and attempt to rebase
+ try {
+ RebaseResult rebaseResult = git.rebase()
+ .setUpstream("refs/heads/master").call();
+ fail("Checkout with conflict should have occured, not "
+ + rebaseResult.getStatus());
+ } catch (JGitInternalException e) {
+ checkFile(theFile, "dirty the file");
+ }
+
+ assertEquals(RepositoryState.SAFE, git.getRepository()
+ .getRepositoryState());
+ }
}