aboutsummaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit.test/tst/org/eclipse/jgit/merge
diff options
context:
space:
mode:
Diffstat (limited to 'org.eclipse.jgit.test/tst/org/eclipse/jgit/merge')
-rw-r--r--org.eclipse.jgit.test/tst/org/eclipse/jgit/merge/ResolveMergerTest.java58
1 files changed, 58 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 a08dbbcc83..255262255a 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
@@ -586,6 +586,64 @@ public class ResolveMergerTest extends RepositoryTestCase {
}
}
+ @Theory
+ public void checkContentMergeNoConflict(MergeStrategy strategy)
+ throws Exception {
+ Git git = Git.wrap(db);
+
+ writeTrashFile("file", "1\n2\n3");
+ git.add().addFilepattern("file").call();
+ RevCommit first = git.commit().setMessage("added file").call();
+
+ writeTrashFile("file", "1master\n2\n3");
+ git.commit().setAll(true).setMessage("modified file on master").call();
+
+ git.checkout().setCreateBranch(true).setStartPoint(first)
+ .setName("side").call();
+ writeTrashFile("file", "1\n2\n3side");
+ RevCommit sideCommit = git.commit().setAll(true)
+ .setMessage("modified file on side").call();
+
+ git.checkout().setName("master").call();
+ MergeResult result =
+ git.merge().setStrategy(strategy).include(sideCommit).call();
+ assertEquals(MergeStatus.MERGED, result.getMergeStatus());
+ String expected = "1master\n2\n3side";
+ assertEquals(expected, read("file"));
+ }
+
+ @Theory
+ public void checkContentMergeConflict(MergeStrategy strategy)
+ throws Exception {
+ Git git = Git.wrap(db);
+
+ writeTrashFile("file", "1\n2\n3");
+ git.add().addFilepattern("file").call();
+ RevCommit first = git.commit().setMessage("added file").call();
+
+ writeTrashFile("file", "1master\n2\n3");
+ git.commit().setAll(true).setMessage("modified file on master").call();
+
+ git.checkout().setCreateBranch(true).setStartPoint(first)
+ .setName("side").call();
+ writeTrashFile("file", "1side\n2\n3");
+ RevCommit sideCommit = git.commit().setAll(true)
+ .setMessage("modified file on side").call();
+
+ git.checkout().setName("master").call();
+ MergeResult result =
+ git.merge().setStrategy(strategy).include(sideCommit).call();
+ assertEquals(MergeStatus.CONFLICTING, result.getMergeStatus());
+ String expected = "<<<<<<< HEAD\n"
+ + "1master\n"
+ + "=======\n"
+ + "1side\n"
+ + ">>>>>>> " + sideCommit.name() + "\n"
+ + "2\n"
+ + "3";
+ assertEquals(expected, read("file"));
+ }
+
/**
* Merging after criss-cross merges. In this case we merge together two
* commits which have two equally good common ancestors