summaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit.test
diff options
context:
space:
mode:
authorRobin Rosenberg <robin.rosenberg@dewire.com>2013-03-15 11:33:08 -0400
committerGerrit Code Review @ Eclipse.org <gerrit@eclipse.org>2013-03-15 11:33:08 -0400
commit0adcbba1495b2f677461c526a8a191c236064f7c (patch)
tree59eace19e030b78fbae130437393f27e6a99f332 /org.eclipse.jgit.test
parente607d2a4d796f8b7abf595b51d6dddb0155cc958 (diff)
parent3cd089f04cf1122e6a9d0a6f842ddd0b46a7a9bd (diff)
downloadjgit-0adcbba1495b2f677461c526a8a191c236064f7c.tar.gz
jgit-0adcbba1495b2f677461c526a8a191c236064f7c.zip
Merge "A folder does not constitute a dirty work tree"
Diffstat (limited to 'org.eclipse.jgit.test')
-rw-r--r--org.eclipse.jgit.test/tst/org/eclipse/jgit/merge/ResolveMergerTest.java77
1 files changed, 77 insertions, 0 deletions
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/merge/ResolveMergerTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/merge/ResolveMergerTest.java
index d8ef2dd6ba..72762437d6 100644
--- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/merge/ResolveMergerTest.java
+++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/merge/ResolveMergerTest.java
@@ -189,6 +189,83 @@ public class ResolveMergerTest extends RepositoryTestCase {
}
/**
+ * An existing directory without tracked content should not prevent merging
+ * a tree where that directory exists.
+ *
+ * @param strategy
+ * @throws Exception
+ */
+ @Theory
+ public void checkUntrackedFolderIsNotAConflict(
+ MergeStrategy strategy) throws Exception {
+ Git git = Git.wrap(db);
+
+ writeTrashFile("d/1", "1");
+ git.add().addFilepattern("d/1").call();
+ RevCommit first = git.commit().setMessage("added d/1").call();
+
+ writeTrashFile("e/1", "4");
+ git.add().addFilepattern("e/1").call();
+ RevCommit masterCommit = git.commit().setMessage("added e/1").call();
+
+ git.checkout().setCreateBranch(true).setStartPoint(first)
+ .setName("side").call();
+ writeTrashFile("f/1", "5");
+ git.add().addFilepattern("f/1").call();
+ git.commit().setAll(true).setMessage("added f/1")
+ .call();
+
+ // Untracked directory e shall not conflict with merged e/1
+ writeTrashFile("e/2", "d two");
+
+ MergeResult mergeRes = git.merge().setStrategy(strategy)
+ .include(masterCommit).call();
+ assertEquals(MergeStatus.MERGED, mergeRes.getMergeStatus());
+ assertEquals(
+ "[d/1, mode:100644, content:1][e/1, mode:100644, content:4][f/1, mode:100644, content:5]",
+ indexState(CONTENT));
+ }
+
+ /**
+ * An existing directory without tracked content should not prevent merging
+ * a file with that name.
+ *
+ * @param strategy
+ * @throws Exception
+ */
+ @Theory
+ public void checkUntrackedEmpytFolderIsNotAConflictWithFile(
+ MergeStrategy strategy)
+ throws Exception {
+ Git git = Git.wrap(db);
+
+ writeTrashFile("d/1", "1");
+ git.add().addFilepattern("d/1").call();
+ RevCommit first = git.commit().setMessage("added d/1").call();
+
+ writeTrashFile("e", "4");
+ git.add().addFilepattern("e").call();
+ RevCommit masterCommit = git.commit().setMessage("added e").call();
+
+ git.checkout().setCreateBranch(true).setStartPoint(first)
+ .setName("side").call();
+ writeTrashFile("f/1", "5");
+ git.add().addFilepattern("f/1").call();
+ git.commit().setAll(true).setMessage("added f/1").call();
+
+ // Untracked empty directory hierarcy e/1 shall not conflict with merged
+ // e/1
+ FileUtils.mkdirs(new File(trash, "e/1"), true);
+
+ MergeResult mergeRes = git.merge().setStrategy(strategy)
+ .include(masterCommit).call();
+ assertEquals(MergeStatus.MERGED, mergeRes.getMergeStatus());
+ assertEquals(
+ "[d/1, mode:100644, content:1][e, mode:100644, content:4][f/1, mode:100644, content:5]",
+ indexState(CONTENT));
+ }
+
+ /**
* Merging two equal subtrees when the index does not contain any file in
* that subtree should lead to a merged state.
*