|
|
@ -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 |
|
|
|
* Merging after criss-cross merges. In this case we merge together two |
|
|
|
* commits which have two equally good common ancestors |
|
|
|
* commits which have two equally good common ancestors |
|
|
|