From 99771f04bcb6b1a79d4b9c5edff21c994104f8da Mon Sep 17 00:00:00 2001 From: Christian Halstrick Date: Tue, 2 Nov 2010 17:39:59 +0100 Subject: Fixed merge algorithm regarding adjacent modifications JGit merge algorithm behaved differently from C Git when we had adjacent modifications. If line 9 was modified by OURS and line 10 by theirs then C Git will return a conflict while JGit was seeing this as independent modifications. This change is not only there to achieve compatibility, but there where also some really wrong merge results produced by JGit in the area of adjacent modifications. Change-Id: I8d77cb59e82638214e45b3cf9ce3a1f1e9b35c70 Signed-off-by: Christian Halstrick --- .../tst/org/eclipse/jgit/merge/MergeAlgorithmTest.java | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'org.eclipse.jgit.test/tst/org/eclipse') diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/merge/MergeAlgorithmTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/merge/MergeAlgorithmTest.java index c929629502..9b4b7146f6 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/merge/MergeAlgorithmTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/merge/MergeAlgorithmTest.java @@ -107,7 +107,7 @@ public class MergeAlgorithmTest extends TestCase { * @throws IOException */ public void testTwoComplicatedModifications() throws IOException { - assertEquals(t("aZY"), + assertEquals(t("a"), merge("abcdefghij", "aZZZZfZhZj", "abYdYYYYiY")); } @@ -153,6 +153,18 @@ public class MergeAlgorithmTest extends TestCase { merge("abcdefghij", "abdefghij", "abZdefghij")); } + public void testInsertVsModify() throws IOException { + assertEquals(t("a"), merge("ab", "abZ", "aXY")); + } + + public void testAdjacentModifications() throws IOException { + assertEquals(t("ad"), merge("abcd", "aZcd", "abYd")); + } + + public void testSeperateModifications() throws IOException { + assertEquals(t("aZcYe"), merge("abcde", "aZcde", "abcYe")); + } + private String merge(String commonBase, String ours, String theirs) throws IOException { MergeResult r = MergeAlgorithm.merge(RawTextComparator.DEFAULT, T(commonBase), T(ours), T(theirs)); -- cgit v1.2.3