t5333: demonstrate various pseudo-merge bugs
Using the test helper introduced via the previous commit, add various failing tests demonstrating bugs in the pseudo-merge implementation. These are all marked as failing with one exception. The "sampleRate=0" test describes a latent bug, which is only reachable through a code path that is itself masked by a separate bug. A future commit will fix that bug, and, in turn, cause the aforementioned test to fail. Accordingly, that commit will mark the test as failing, and it will be re-marked as passing in a separate commit which fixes the once-latent bug. For the rest: the following commits will explain and fix the underlying bugs in detail. Signed-off-by: Taylor Blau <me@ttaylorr.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Taylor Blau committed
May 11, 2026 at 20:46 UTC
49369d8290c3a5c95d835df85fdf53eba7562496
1 file changed
+198
t/t5333-pseudo-merge-bitmaps.sh
+198
index 1f7a5d82ee..0e9638c31c 100755
--- a/t/t5333-pseudo-merge-bitmaps.sh
+++ b/t/t5333-pseudo-merge-bitmaps.sh
@@ -462,4 +462,202 @@ test_expect_success 'use pseudo-merge in boundary traversal' '
)
'
+test_expect_failure 'apply pseudo-merges during fill-in traversal' '
+ test_when_finished "rm -fr pseudo-merge-fill-in-traversal" &&
+ git init pseudo-merge-fill-in-traversal &&
+ (
+ cd pseudo-merge-fill-in-traversal &&
+
+ git config bitmapPseudoMerge.test.pattern refs/tags/ &&
+ git config bitmapPseudoMerge.test.maxMerges 1 &&
+ git config bitmapPseudoMerge.test.stableThreshold never &&
+
+ test_commit_bulk 64 &&
+ tag_everything &&
+ git repack -ad &&
+
+ pack=$(ls .git/objects/pack/pack-*.pack) &&
+ git rev-parse HEAD~63 >in &&
+ test-tool bitmap write "$(basename $pack)" <in &&
+
+ test_pseudo_merges >merges &&
+ test_line_count = 1 merges &&
+
+ test_commit stale &&
+
+ git rev-list --count --objects HEAD >expect &&
+
+ : >trace2.txt &&
+ GIT_TRACE2_EVENT=$PWD/trace2.txt \
+ git rev-list --count --objects --use-bitmap-index HEAD >actual &&
+ test_pseudo_merges_satisfied 1 <trace2.txt &&
+
+ test_cmp expect actual
+ )
+'
+
+test_expect_failure 'apply pseudo-merges from multiple groups during fill-in' '
+ test_when_finished "rm -fr pseudo-merge-fill-in-multi" &&
+ git init pseudo-merge-fill-in-multi &&
+ (
+ cd pseudo-merge-fill-in-multi &&
+
+ test_commit base &&
+ base=$(git rev-parse HEAD) &&
+
+ for side in left right
+ do
+ git checkout -B $side base &&
+
+ test_commit_bulk --id=$side 64 &&
+ git rev-list --no-object-names HEAD --not $base >in &&
+ while read oid
+ do
+ echo "create refs/group-$side/$oid $oid" || return 1
+ done <in | git update-ref --stdin || return 1
+ done &&
+
+ git checkout left &&
+ git merge right &&
+ git repack -ad &&
+
+ git config bitmapPseudoMerge.left.pattern "refs/group-left/" &&
+ git config bitmapPseudoMerge.left.maxMerges 1 &&
+ git config bitmapPseudoMerge.left.stableThreshold never &&
+
+ git config bitmapPseudoMerge.right.pattern "refs/group-right/" &&
+ git config bitmapPseudoMerge.right.maxMerges 1 &&
+ git config bitmapPseudoMerge.right.stableThreshold never &&
+
+ pack="$(ls .git/objects/pack/pack-*.pack)" &&
+ git rev-parse "$base" >in &&
+ test-tool bitmap write "$(basename $pack)" <in &&
+
+ test_pseudo_merges >merges &&
+ test_line_count = 2 merges &&
+
+ test_commit stale &&
+
+ git rev-list --count --objects HEAD >expect &&
+
+ : >trace2.txt &&
+ GIT_TRACE2_EVENT=$PWD/trace2.txt \
+ git rev-list --count --objects --use-bitmap-index HEAD >actual &&
+ test_pseudo_merges_satisfied 2 <trace2.txt &&
+
+ test_cmp expect actual
+ )
+'
+
+test_expect_failure 'apply pseudo-merges with overlapping groups during fill-in' '
+ test_when_finished "rm -fr pseudo-merge-fill-in-overlap" &&
+ git init pseudo-merge-fill-in-overlap &&
+ (
+ cd pseudo-merge-fill-in-overlap &&
+
+ test_commit_bulk 64 &&
+ tag_everything &&
+ git repack -ad &&
+
+ pack="$(ls .git/objects/pack/pack-*.pack)" &&
+
+ # Use two pseudo-merge group patterns that both match
+ # refs/tags/, so every tagged commit belongs to both
+ # groups. This exercises the extended lookup table
+ # path in apply_pseudo_merges_for_commit().
+ git config bitmapPseudoMerge.all.pattern "refs/tags/" &&
+ git config bitmapPseudoMerge.all.maxMerges 1 &&
+ git config bitmapPseudoMerge.all.stableThreshold never &&
+
+ git config bitmapPseudoMerge.tags.pattern "refs/tags/" &&
+ git config bitmapPseudoMerge.tags.maxMerges 1 &&
+ git config bitmapPseudoMerge.tags.stableThreshold never &&
+
+ git rev-parse HEAD~63 >in &&
+ test-tool bitmap write "$(basename $pack)" <in &&
+
+ test_pseudo_merges >merges &&
+ test_line_count = 2 merges &&
+
+ test_commit stale &&
+
+ git rev-list --count --objects HEAD >expect &&
+
+ : >trace2.txt &&
+ GIT_TRACE2_EVENT=$PWD/trace2.txt \
+ git rev-list --count --objects --use-bitmap-index HEAD >actual &&
+ test_pseudo_merges_satisfied 2 <trace2.txt &&
+
+ test_cmp expect actual
+ )
+'
+
+test_expect_failure 'pseudo-merge commits are correctly classified by date' '
+ test_when_finished "rm -fr pseudo-merge-date-classification" &&
+ git init pseudo-merge-date-classification &&
+ (
+ cd pseudo-merge-date-classification &&
+
+ test_commit_bulk 64 &&
+ tag_everything &&
+ git repack -ad &&
+
+ pack="$(ls .git/objects/pack/pack-*.pack)" &&
+
+ # Configure two pseudo-merge groups: one that only
+ # matches "stable" refs (older than one month), and one
+ # that matches all refs. With 64 freshly-created tags
+ # (all younger than one month) the stable group should
+ # have zero pseudo-merges and the catch-all group should
+ # have one.
+ #
+ # Use GIT_TEST_DATE_NOW to align "now" (and therefore
+ # "1.month.ago") with the test_tick timestamps so that
+ # the commits are within the last month.
+ #
+ # This exercises the date-based classification in
+ # find_pseudo_merge_group_for_ref(), which requires
+ # that commits are parsed before inspecting their date.
+ git config bitmapPseudoMerge.stable.pattern "refs/tags/" &&
+ git config bitmapPseudoMerge.stable.maxMerges 64 &&
+ git config bitmapPseudoMerge.stable.stableThreshold never &&
+ git config bitmapPseudoMerge.stable.threshold 1.month.ago &&
+
+ git config bitmapPseudoMerge.all.pattern "refs/tags/" &&
+ git config bitmapPseudoMerge.all.maxMerges 1 &&
+ git config bitmapPseudoMerge.all.stableThreshold never &&
+ git config bitmapPseudoMerge.all.threshold now &&
+
+ git rev-parse HEAD~63 >in &&
+ GIT_TEST_DATE_NOW=$test_tick \
+ test-tool bitmap write "$(basename $pack)" <in &&
+
+ test_pseudo_merges >merges &&
+ test_line_count = 1 merges
+ )
+'
+
+test_expect_success 'sampleRate=0 does not cause division by zero' '
+ test_when_finished "rm -fr pseudo-merge-sample-rate-zero" &&
+ git init pseudo-merge-sample-rate-zero &&
+ (
+ cd pseudo-merge-sample-rate-zero &&
+
+ test_commit_bulk 64 &&
+ tag_everything &&
+ git repack -ad &&
+
+ pack="$(ls .git/objects/pack/pack-*.pack)" &&
+
+ git config bitmapPseudoMerge.test.pattern "refs/tags/" &&
+ git config bitmapPseudoMerge.test.maxMerges 1 &&
+ git config bitmapPseudoMerge.test.sampleRate 0 &&
+ git config bitmapPseudoMerge.test.threshold now &&
+ git config bitmapPseudoMerge.test.stableThreshold never &&
+
+ git rev-parse HEAD~63 >in &&
+ test-tool bitmap write "$(basename $pack)" <in
+ )
+'
+
test_done