Merge branch 'jc/t2300-setup' into HEAD
[gitweb.git] / t / t6010-merge-base.sh
index abb5728b34b5eaba80d62f0e7d2b2c872dad4118..e0c5f44cac0290c6e15c5360b0cc7c1f4d486614 100755 (executable)
@@ -215,11 +215,13 @@ test_expect_success 'criss-cross merge-base for octopus-step' '
        git reset --hard E &&
        test_commit CC2 &&
        test_tick &&
-       git merge -s ours CC1 &&
+       # E is a root commit unrelated to MMR root on which CC1 is based
+       git merge -s ours --allow-unrelated-histories CC1 &&
        test_commit CC-o &&
        test_commit CCB &&
        git reset --hard CC1 &&
-       git merge -s ours CC2 &&
+       # E is a root commit unrelated to MMR root on which CC1 is based
+       git merge -s ours --allow-unrelated-histories CC2 &&
        test_commit CCA &&
 
        git rev-parse CC1 CC2 >expected &&
@@ -230,6 +232,34 @@ test_expect_success 'criss-cross merge-base for octopus-step' '
        test_cmp expected.sorted actual.sorted
 '
 
+test_expect_success 'using reflog to find the fork point' '
+       git reset --hard &&
+       git checkout -b base $E &&
+
+       (
+               for count in 1 2 3
+               do
+                       git commit --allow-empty -m "Base commit #$count" &&
+                       git rev-parse HEAD >expect$count &&
+                       git checkout -B derived &&
+                       git commit --allow-empty -m "Derived #$count" &&
+                       git rev-parse HEAD >derived$count &&
+                       git checkout -B base $E || exit 1
+               done
+
+               for count in 1 2 3
+               do
+                       git merge-base --fork-point base $(cat derived$count) >actual &&
+                       test_cmp expect$count actual || exit 1
+               done
+
+       ) &&
+       # check that we correctly default to HEAD
+       git checkout derived &&
+       git merge-base --fork-point base >actual &&
+       test_cmp expect3 actual
+'
+
 test_expect_success 'merge-base --octopus --all for complex tree' '
        # Best common ancestor for JE, JAA and JDD is JC
        #             JE