#!/bin/sh test_description='pseudo-merge bitmaps' GIT_TEST_MULTI_PACK_INDEX_WRITE_BITMAP=0 TEST_PASSES_SANITIZE_LEAK=true . ./test-lib.sh test_pseudo_merges () { test-tool bitmap dump-pseudo-merges } test_pseudo_merge_commits () { test-tool bitmap dump-pseudo-merge-commits "$1" } test_pseudo_merges_satisfied () { test_trace2_data bitmap pseudo_merges_satisfied "$1" } test_pseudo_merges_cascades () { test_trace2_data bitmap pseudo_merges_cascades "$1" } test_pseudo_merges_reused () { test_trace2_data pack-bitmap-write building_bitmaps_pseudo_merge_reused "$1" } tag_everything () { git rev-list --all --no-object-names >in && perl -lne ' print "create refs/tags/" . $. . " " . $1 if /([0-9a-f]+)/ ' expect && : >trace2.txt && GIT_TRACE2_EVENT=$PWD/trace2.txt \ git rev-list --count --all --objects --use-bitmap-index >actual && test_pseudo_merges_satisfied 0 merges && test_must_be_empty merges && test_cmp expect actual ' test_expect_success 'pseudo-merges accurately represent their objects' ' test_config bitmapPseudoMerge.test.pattern "refs/tags/" && test_config bitmapPseudoMerge.test.maxMerges 8 && test_config bitmapPseudoMerge.test.stableThreshold never && git repack -adb && test_pseudo_merges >merges && test_line_count = 8 merges && for i in $(test_seq 0 $(($(wc -l commits && git rev-list --objects --no-object-names --stdin expect.raw && test-tool bitmap dump-pseudo-merge-objects $i >actual.raw && sort -u expect && sort -u actual && test_cmp expect actual || return 1 done ' test_expect_success 'bitmap traversal with pseudo-merges' ' : >trace2.txt && GIT_TRACE2_EVENT=$PWD/trace2.txt \ git rev-list --count --all --objects --use-bitmap-index >actual && git rev-list --count --all --objects >expect && test_pseudo_merges_satisfied 8 trace2.txt && GIT_TRACE2_EVENT=$PWD/trace2.txt \ git rev-list --count --all --objects --use-bitmap-index >actual && git rev-list --count --all --objects >expect && test_pseudo_merges_satisfied 8 merges && test_line_count = 1 merges && test_pseudo_merge_commits 0 >commits && test-tool bitmap list-commits >bitmaps && bitmaps_nr="$(wc -l expect && test $(cat expect) -eq $(wc -l merges && test_line_count = 1 merges && test_pseudo_merge_commits 0 >oids && git cat-file --batch commits && test $(wc -l in && git update-ref --stdin merges && merges_nr="$(wc -l oids && git cat-file --batch commits && expect="$(grep -c "^committer.*$old +0000$" commits)" && actual="$(wc -l oids && git cat-file --batch commits && test $(wc -l err && cat >expect <<-EOF && fatal: pseudo-merge group ${SQ}test${SQ} has unstable threshold before stable one EOF test_cmp expect err ' test_expect_success 'pseudo-merge pattern with capture groups' ' git init pseudo-merge-captures && ( cd pseudo-merge-captures && test_commit_bulk 128 && tag_everything && for r in $(test_seq 8) do test_commit_bulk 16 && git rev-list HEAD~16.. >in && perl -lne "print \"create refs/remotes/$r/tags/\$. \$_\"" refs && test_pseudo_merges >merges && for m in $(test_seq 0 $(($(wc -l oids && grep -f oids refs | perl -lne "print \$1 if /refs\/remotes\/([0-9]+)/" | sort -u || return 1 done >remotes && test $(wc -l merges && test_line_count = 2 merges && test_pseudo_merge_commits 0 >commits-0.raw && test_pseudo_merge_commits 1 >commits-1.raw && sort commits-0.raw >commits-0 && sort commits-1.raw >commits-1 && comm -12 commits-0 commits-1 >overlap && test_line_count -gt 0 overlap ) ' test_expect_success 'pseudo-merge overlap traversal' ' ( cd pseudo-merge-overlap && : >trace2.txt && GIT_TRACE2_EVENT=$PWD/trace2.txt \ git rev-list --count --all --objects --use-bitmap-index >actual && git rev-list --count --all --objects >expect && test_pseudo_merges_satisfied 2 trace2.txt && GIT_TRACE2_EVENT=$PWD/trace2.txt \ git rev-list --count --all --objects --use-bitmap-index >actual && git rev-list --count --all --objects >expect && test_pseudo_merges_satisfied 2 merges && test_line_count = 2 merges && test_pseudo_merge_commits 0 >stable-oids.before && test_pseudo_merge_commits 1 >unstable-oids.before && : >trace2.txt && GIT_TRACE2_EVENT=$PWD/trace2.txt git \ -c bitmapPseudoMerge.test.pattern="refs/tags/" \ -c bitmapPseudoMerge.test.maxMerges=2 \ -c bitmapPseudoMerge.test.threshold=now \ -c bitmapPseudoMerge.test.stableThreshold=$(($unstable - 1)) \ -c bitmapPseudoMerge.test.stableSize=512 \ repack -adb && test_pseudo_merges_reused 1 merges && test_line_count = 3 merges && test_pseudo_merge_commits 0 >stable-oids.after && for i in 1 2 do test_pseudo_merge_commits $i || return 1 done >unstable-oids.after && sort -u expect && sort -u actual && test_cmp expect actual && sort -u expect && sort -u actual && test_cmp expect actual ) ' test_expect_success 'empty pseudo-merge group' ' git init pseudo-merge-empty-group && ( cd pseudo-merge-empty-group && # Ensure that a pseudo-merge group with no unstable # commits does not generate an empty pseudo-merge # bitmap. git config bitmapPseudoMerge.empty.pattern refs/ && test_commit base && git repack -adb && test-tool bitmap dump-pseudo-merges >merges && test_line_count = 1 merges && test 0 -eq "$(grep -c commits=0 pseudo-merges && test_line_count = 1 pseudo-merges && git rev-parse A >expect && test-tool bitmap list-commits >actual && test_cmp expect actual && test-tool bitmap dump-pseudo-merge-commits 0 >actual && test_cmp expect actual ) ' test_done