aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAxel Richard2013-11-28 08:14:32 (EST)
committerMatthias Sohn2013-12-02 16:55:55 (EST)
commit1128326adde8f2c98bddc58ce1879fca7b2cd41f (patch)
treec78c3fab2dd41a0974589d0b807aed8c08fa91e2
parent99608f0b9a10abe0f8426f0ff5bc51eb6a2ae866 (diff)
downloadjgit-1128326adde8f2c98bddc58ce1879fca7b2cd41f.zip
jgit-1128326adde8f2c98bddc58ce1879fca7b2cd41f.tar.gz
jgit-1128326adde8f2c98bddc58ce1879fca7b2cd41f.tar.bz2
Add pgm test for checkout of existing branch with checkout conflictrefs/changes/59/19059/8
Add a test that checks out an existing branch with a dirty working tree and involves a checkout conflict. This test should pass with a message: "error: Your local changes to the following files would be overwritten by checkout: a". Change-Id: I5428a04a7630d9e0101404ea1aedd796f127bd7d Signed-off-by: Axel Richard <axel.richard@obeo.fr> Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
-rw-r--r--org.eclipse.jgit.pgm.test/tst/org/eclipse/jgit/pgm/CheckoutTest.java26
1 files changed, 26 insertions, 0 deletions
diff --git a/org.eclipse.jgit.pgm.test/tst/org/eclipse/jgit/pgm/CheckoutTest.java b/org.eclipse.jgit.pgm.test/tst/org/eclipse/jgit/pgm/CheckoutTest.java
index 48cb5c5..a6ea48c 100644
--- a/org.eclipse.jgit.pgm.test/tst/org/eclipse/jgit/pgm/CheckoutTest.java
+++ b/org.eclipse.jgit.pgm.test/tst/org/eclipse/jgit/pgm/CheckoutTest.java
@@ -42,8 +42,11 @@
*/
package org.eclipse.jgit.pgm;
+import java.io.File;
+
import org.eclipse.jgit.api.Git;
import org.eclipse.jgit.lib.CLIRepositoryTestCase;
+import org.eclipse.jgit.util.FileUtils;
import org.junit.Assert;
import org.junit.Test;
@@ -107,6 +110,29 @@ public class CheckoutTest extends CLIRepositoryTestCase {
assertEquals("", execute("git checkout HEAD"));
}
+ @Test
+ public void testCheckoutExistingBranchWithConflict() throws Exception {
+ Git git = new Git(db);
+ writeTrashFile("a", "Hello world a");
+ git.add().addFilepattern(".").call();
+ git.commit().setMessage("commit file a").call();
+ git.branchCreate().setName("branch_1").call();
+ git.rm().addFilepattern("a").call();
+ FileUtils.mkdirs(new File(db.getWorkTree(), "a"));
+ writeTrashFile("a/b", "Hello world b");
+ git.add().addFilepattern("a/b").call();
+ git.commit().setMessage("commit folder a").call();
+ git.rm().addFilepattern("a").call();
+ writeTrashFile("a", "New Hello world a");
+ git.add().addFilepattern(".").call();
+
+ String[] execute = execute("git checkout branch_1");
+ Assert.assertEquals(
+ "error: Your local changes to the following files would be overwritten by checkout:",
+ execute[0]);
+ Assert.assertEquals("\ta", execute[1]);
+ }
+
static private void assertEquals(String expected, String[] actual) {
// if there is more than one line, ignore last one if empty
Assert.assertEquals(