Browse Source

ResolveMergerTest: Add tests for content merges

Change-Id: I2b85cc239e9b3090426c956cbf9af3deb4106a41
stable-4.8
Dave Borowitz 8 years ago
parent
commit
edb6593ef0
  1. 58
      org.eclipse.jgit.test/tst/org/eclipse/jgit/merge/ResolveMergerTest.java

58
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

Loading…
Cancel
Save