t6600: add test for merge-base early exit with clock skew
Add a topology where the correct merge base (M2) has a lower committer date than its ancestor (M1) due to clock skew. With a v1 commit graph (topological levels only, no corrected commit dates), paint_down_to_common() falls back to commit-date ordering. In that mode, M1 pops before M2, acquires both paint sides, and the !FIND_ALL early exit fires -- returning the wrong merge base. Mark the test as test_expect_failure to document the bug; the next commit will fix it. Signed-off-by: Kristofer Karlsson <krka@spotify.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Kristofer Karlsson committed
Jun 29, 2026 at 13:19 UTC
18cf52c8a590d00c333d3d20edc2cf8c11c8ab92
1 file changed
+41
t/t6600-test-reach.sh
+41
@@ -49,6 +49,42 @@ test_expect_success 'setup' '
49
git tag -a -m "$x-$i" tag-$x-$i commit-$x-$i || return 1
50
done
51
done &&
52
+ # Build a topology with clock skew to test the !FIND_ALL early
53
+ # exit in paint_down_to_common(). M2 is the correct merge base
54
+ # of P1 and P2, but its ancestor M1 has a higher committer date
55
+ # due to clock skew. With date-only ordering (v1 commit graph
56
+ # without corrected commit dates), M1 pops from the queue first,
57
+ # gets both paint sides, and the early exit fires before M2 is
58
+ # ever visited.
59
+ #
60
+ # P1 P2 @7000
61
+ # | / \
62
+ # A B D @6000
63
+ # / \ | |
64
+ # | M2--+ | @2000 (correct merge base)
65
+ # \ | |
66
+ # M1--------+ @5000 (clock skew: date > M2)
67
+ # |
68
+ # root @1000
69
+ #
70
+ git checkout --orphan skew-orphan &&
71
+ skew_tree=$(git mktree </dev/null) &&
72
+ skew_commit () {
73
+ GIT_COMMITTER_DATE="@$1 +0000" GIT_AUTHOR_DATE="@$1 +0000" \
74
+ git commit-tree -m "$2" "$skew_tree" $3 $4 $5 $6
75
+ } &&
76
+ skew_root=$(skew_commit 1000 root) &&
77
+ skew_M1=$(skew_commit 5000 M1 -p "$skew_root") &&
78
+ skew_M2=$(skew_commit 2000 M2 -p "$skew_M1") &&
79
+ skew_A=$(skew_commit 6000 A -p "$skew_M1" -p "$skew_M2") &&
80
+ skew_B=$(skew_commit 6000 B -p "$skew_M2") &&
81
+ skew_D=$(skew_commit 6000 D -p "$skew_M1") &&
82
+ skew_P1=$(skew_commit 7000 P1 -p "$skew_A") &&
83
+ skew_P2=$(skew_commit 7000 P2 -p "$skew_B" -p "$skew_D") &&
84
+ git branch -f skew-P1 "$skew_P1" &&
85
+ git branch -f skew-P2 "$skew_P2" &&
86
+ git tag skew-M2 "$skew_M2" &&
87
+
88
git commit-graph write --reachable &&
89
mv .git/objects/info/commit-graph commit-graph-full &&
90
chmod u+w commit-graph-full &&
@@ -922,4 +958,9 @@ test_expect_success 'merge-base without --all is one of --all results' '
958
grep -F -f single all
959
'
960
961
+test_expect_failure 'merge-base without --all, clock skew, v1 commit-graph' '
962
+ git rev-parse skew-M2 >expect &&
963
+ merge_base_all_modes skew-P1 skew-P2
964
+'
965
+
966
test_done