diff options
author | Robin Stocker <robin@nibor.org> | 2012-09-22 21:27:01 +0200 |
---|---|---|
committer | Robin Stocker <robin@nibor.org> | 2012-09-23 02:41:51 +0200 |
commit | ac805874f72fe2c6193bc959865fb525e069e45e (patch) | |
tree | e594580e7d5a261f8658806c3699effc2b9ec854 /org.eclipse.jgit.test/tst/org | |
parent | eb5b506acdd22c3e5d97d9b3efaf978659ef07f4 (diff) | |
download | jgit-ac805874f72fe2c6193bc959865fb525e069e45e.tar.gz jgit-ac805874f72fe2c6193bc959865fb525e069e45e.zip |
Refuse to checkout unmerged paths from index
Without this check, the checkout was done but the result was a "both
deleted" status when inspecting it with C Git.
Found this while working on bug 390147.
Change-Id: Ic3693f2c651827239e838bf7f37da842a7ae9707
Diffstat (limited to 'org.eclipse.jgit.test/tst/org')
-rw-r--r-- | org.eclipse.jgit.test/tst/org/eclipse/jgit/api/PathCheckoutCommandTest.java | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/PathCheckoutCommandTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/PathCheckoutCommandTest.java index 243d791cd2..d37f57293d 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/PathCheckoutCommandTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/PathCheckoutCommandTest.java @@ -47,11 +47,13 @@ import static org.junit.Assert.assertEquals; import java.io.File; import java.io.IOException; +import org.eclipse.jgit.api.errors.JGitInternalException; import org.eclipse.jgit.dircache.DirCache; import org.eclipse.jgit.dircache.DirCacheEntry; import org.eclipse.jgit.errors.NoWorkTreeException; import org.eclipse.jgit.lib.ConfigConstants; import org.eclipse.jgit.lib.ObjectReader; +import org.eclipse.jgit.lib.RepositoryState; import org.eclipse.jgit.lib.RepositoryTestCase; import org.eclipse.jgit.lib.StoredConfig; import org.eclipse.jgit.revwalk.RevCommit; @@ -243,4 +245,23 @@ public class PathCheckoutCommandTest extends RepositoryTestCase { assertEquals("1", read(test)); assertEquals("a", read(test2)); } + + @Test(expected = JGitInternalException.class) + public void testCheckoutOfConflictingFileShouldThrow() + throws Exception { + // Setup + git.checkout().setCreateBranch(true).setName("conflict") + .setStartPoint(initialCommit).call(); + writeTrashFile(FILE1, "Conflicting"); + RevCommit conflict = git.commit().setAll(true) + .setMessage("Conflicting change").call(); + + git.checkout().setName("master").call(); + + git.merge().include(conflict).call(); + assertEquals(RepositoryState.MERGING, db.getRepositoryState()); + + // Now check out the conflicting path + git.checkout().addPath(FILE1).call(); + } } |