t6600: add clock-skew topologies and step counts for edge cases

Add topologies and tests exercising paint_down_to_common() under clock skew, where commit-date ordering (v1 commit-graph without corrected commit dates) violates the topological invariant that children are dequeued before parents: - se-*: side-exhaustion fires too early when one paint side fully drains from the queue while a low-date ancestor on the other side is still queued - se2-*: side-exhaustion returns a too-deep merge base because the correct (closer) base never receives both paint sides Also add step counts to the edge-case tests from the previous commit, a mixed finite/INFINITY generation topology exercising the transition from INFINITY-generation commits to graph-backed commits, and step counts for the grid-based merge-base test. Signed-off-by: Kristofer Karlsson <krka@spotify.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Kristofer Karlsson committed Jul 11, 2026 at 13:27 UTC b9bc40f1414642d8245a71c80e8396835c88b60c
1 file changed +96 -2
t/t6600-test-reach.sh
+96 -2
@@ -140,6 +140,48 @@ test_expect_success 'setup' '
140 git branch -f pi-X-br "$pi_x" &&
141 git tag pi-X "$pi_x" &&
142
143 + # Clock-skew topology for side-exhaustion testing.
144 + # D is the correct merge base but has a higher committer date
145 + # than C (its child). With date ordering, D would be dequeued
146 + # before C, causing side-exhaustion to fire too early.
147 + # Generation ordering prevents this by visiting children
148 + # before parents regardless of dates.
149 + #
150 + # se-A (date 7000) --> se-C (date 3000) --> se-D (date 5000) --> se-root (date 4000)
151 + # se-B (date 6000) --> se-D
152 + #
153 + se_root=$(skew_commit 4000 se-root) &&
154 + se_D=$(skew_commit 5000 se-D -p "$se_root") &&
155 + se_C=$(skew_commit 3000 se-C -p "$se_D") &&
156 + se_A=$(skew_commit 7000 se-A -p "$se_C") &&
157 + se_B=$(skew_commit 6000 se-B -p "$se_D") &&
158 + git branch -f se-A "$se_A" &&
159 + git branch -f se-B "$se_B" &&
160 + git tag se-D "$se_D" &&
161 +
162 + # Clock-skew topology with redundant ancestor for
163 + # side-exhaustion testing. MB1 is the correct merge base;
164 + # MB2 is its parent. A reaches MB2 via E (high date) and
165 + # MB1 via C (low date). B reaches MB1 via D. With date
166 + # ordering, side-exhaustion would fire before C is dequeued,
167 + # missing MB1. Generation ordering ensures both are found.
168 + #
169 + # se2-A (date 8000) --> se2-C (date 2000) --> se2-MB1 (date 5000) --> se2-MB2 (date 4000) --> se2-root (date 1000)
170 + # se2-A --> se2-E (date 6500) --> se2-MB2
171 + # se2-B (date 7000) --> se2-D (date 6000) --> se2-MB1
172 + #
173 + se2_root=$(skew_commit 1000 se2-root) &&
174 + se2_MB2=$(skew_commit 4000 se2-MB2 -p "$se2_root") &&
175 + se2_MB1=$(skew_commit 5000 se2-MB1 -p "$se2_MB2") &&
176 + se2_C=$(skew_commit 2000 se2-C -p "$se2_MB1") &&
177 + se2_D=$(skew_commit 6000 se2-D -p "$se2_MB1") &&
178 + se2_E=$(skew_commit 6500 se2-E -p "$se2_MB2") &&
179 + se2_A=$(skew_commit 8000 se2-A -p "$se2_C" -p "$se2_E") &&
180 + se2_B=$(skew_commit 7000 se2-B -p "$se2_D") &&
181 + git branch -f se2-A "$se2_A" &&
182 + git branch -f se2-B "$se2_B" &&
183 + git tag se2-MB1 "$se2_MB1" &&
184 +
185 git commit-graph write --reachable &&
186 mv .git/objects/info/commit-graph commit-graph-full &&
187 chmod u+w commit-graph-full &&
@@ -323,7 +365,8 @@ test_expect_success 'get_merge_bases_many:pending-stale' '
365 echo "get_merge_bases_many(A,X):" &&
366 git rev-parse ps-B
367 } >expect &&
326 - test_all_modes get_merge_bases_many
368 + test_all_modes get_merge_bases_many &&
369 + test_paint_down_steps 6 6 6 6
370 '
371
372 test_expect_success 'get_merge_bases_many:infinity-both-sides' '
@@ -337,7 +380,34 @@ test_expect_success 'get_merge_bases_many:infinity-both-sides' '
380 echo "get_merge_bases_many(A,X):" &&
381 git rev-parse pi-B
382 } >expect &&
340 - test_all_modes get_merge_bases_many
383 + test_all_modes get_merge_bases_many &&
384 + test_paint_down_steps 5 5 5 5
385 +'
386 +
387 +test_expect_success 'setup mixed finite/INFINITY topology' '
388 + # Create a commit outside all saved commit-graph files so it always
389 + # has INFINITY generation, while its parent (ps-X) is in the graph
390 + # with a finite generation. Use the ps-* orphan topology so we do
391 + # not pollute the grid-based rev-list tests.
392 + git checkout ps-X &&
393 + test_env GIT_TEST_COMMIT_GRAPH= test_commit pm-INF
394 +'
395 +
396 +test_expect_success 'get_merge_bases_many:mixed-finite-infinity' '
397 + # One tip (pm-INF) is outside the commit-graph with INFINITY
398 + # generation; the other (ps-B) is in the graph with finite
399 + # generation. The walk starts in the INFINITY region and crosses
400 + # into the finite region where side-exhaustion can fire.
401 + cat >input <<-\EOF &&
402 + A:pm-INF
403 + X:ps-B
404 + EOF
405 + {
406 + echo "get_merge_bases_many(A,X):" &&
407 + git rev-parse ps-X
408 + } >expect &&
409 + test_all_modes get_merge_bases_many &&
410 + test_paint_down_steps 3 3 3 3
411 '
412
413 test_expect_success 'merge-base --all commit-walk steps' '
@@ -347,6 +417,30 @@ test_expect_success 'merge-base --all commit-walk steps' '
417 test_paint_down_steps 81 80 81 81
418 '
419
420 +test_expect_success 'merge-base --all with clock skew (side-exhaustion)' '
421 + # Verify correct merge base under clock skew. se-D (the
422 + # merge base) has a higher date than its child se-C.
423 + # Generation ordering ensures se-C is visited before se-D,
424 + # so P1 paint propagates correctly and se-D is found.
425 + >input &&
426 + git rev-parse se-D >expect &&
427 + run_all_modes git merge-base --all se-A se-B &&
428 + test_paint_down_steps 6 4 6 6
429 +'
430 +
431 +test_expect_success 'merge-base --all with clock skew and redundant ancestor (side-exhaustion)' '
432 + # Verify correct merge base when clock skew could cause a
433 + # too-deep result. MB1 is the correct merge base; MB2 is
434 + # its ancestor. A reaches MB2 via E (high date) and MB1
435 + # via C (low date). Generation ordering ensures C is
436 + # visited before side-exhaustion fires, so MB1 is found
437 + # and remove_redundant correctly discards MB2.
438 + >input &&
439 + git rev-parse se2-MB1 >expect &&
440 + run_all_modes git merge-base --all se2-A se2-B &&
441 + test_paint_down_steps 8 7 8 8
442 +'
443 +
444 test_expect_success 'reduce_heads' '
445 cat >input <<-\EOF &&
446 X:commit-1-10