Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/git/blob/master/t/t5333-pseudo-merge-bitmaps.sh # git [Ported from github.com/git/git] Sync with Git 2.56.1 Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `master` Branches Tags History `git / t / t5333-pseudo-merge-bitmaps.sh` 706 lines ยท 19729 bytes Raw Blame History 1 #!/bin/sh 2 3 test_description='pseudo-merge bitmaps' 4 5 GIT_TEST_MULTI_PACK_INDEX_WRITE_BITMAP=0 6 7 . ./test-lib.sh 8 9 test_pseudo_merges () { 10 test-tool bitmap dump-pseudo-merges 11 } 12 13 test_pseudo_merge_commits () { 14 test-tool bitmap dump-pseudo-merge-commits "$1" 15 } 16 17 test_pseudo_merges_satisfied () { 18 test_trace2_data bitmap pseudo_merges_satisfied "$1" 19 } 20 21 test_pseudo_merges_cascades () { 22 test_trace2_data bitmap pseudo_merges_cascades "$1" 23 } 24 25 test_pseudo_merges_reused () { 26 test_trace2_data pack-bitmap-write building_bitmaps_pseudo_merge_reused "$1" 27 } 28 29 tag_everything () { 30 git rev-list --all --no-object-names >in && 31 sed 's|\(.*\)|create refs/tags/\1 \1|' in | 32 git update-ref --stdin 33 } 34 35 test_expect_success 'setup' ' 36 test_commit_bulk 512 && 37 tag_everything 38 ' 39 40 test_expect_success 'bitmap traversal without pseudo-merges' ' 41 git repack -adb && 42 43 git rev-list --count --all --objects >expect && 44 45 : >trace2.txt && 46 GIT_TRACE2_EVENT=$PWD/trace2.txt \ 47 git rev-list --count --all --objects --use-bitmap-index >actual && 48 49 test_pseudo_merges_satisfied 0 merges && 52 test_must_be_empty merges && 53 test_cmp expect actual && 54 55 : >trace2.txt && 56 GIT_TRACE2_EVENT=$PWD/trace2.txt \ 57 git rev-list --objects --use-bitmap-index HEAD HEAD >/dev/null && 58 59 # The first HEAD initializes base from its position-zero bitmap. The 60 # duplicate root should not count as another bitmap hit. 61 test_trace2_data bitmap bitmap/hits 1 merges && 72 test_line_count = 8 merges && 73 74 for i in $(test_seq 0 $(($(wc -l commits && 77 78 git rev-list --objects --no-object-names --stdin expect.raw && 79 test-tool bitmap dump-pseudo-merge-objects $i >actual.raw && 80 81 sort -u expect && 82 sort -u actual && 83 84 test_cmp expect actual || return 1 85 done 86 ' 87 88 test_expect_success 'bitmap traversal with pseudo-merges' ' 89 : >trace2.txt && 90 GIT_TRACE2_EVENT=$PWD/trace2.txt \ 91 git rev-list --count --all --objects --use-bitmap-index >actual && 92 git rev-list --count --all --objects >expect && 93 94 test_pseudo_merges_satisfied 8 trace2.txt && 107 GIT_TRACE2_EVENT=$PWD/trace2.txt \ 108 git rev-list --count --all --objects --use-bitmap-index >actual && 109 git rev-list --count --all --objects >expect && 110 111 test_pseudo_merges_satisfied 8 merges && 128 test_line_count = 1 merges && 129 test_pseudo_merge_commits 0 >commits && 130 131 test-tool bitmap list-commits >bitmaps && 132 bitmaps_nr="$(wc -l expect && 136 137 test $(cat expect) -eq $(wc -l merges && 167 test_line_count = 1 merges && 168 169 test_pseudo_merge_commits 0 >oids && 170 git cat-file --batch commits && 171 172 test $(wc -l in && 189 git update-ref --stdin merges && 202 merges_nr="$(wc -l oids && 207 git cat-file --batch commits && 208 209 expect="$(grep -c "^committer.*$old +0000$" commits)" && 210 actual="$(wc -l oids && 216 git cat-file --batch commits && 217 test $(wc -l err && 228 229 cat >expect <<-EOF && 230 fatal: pseudo-merge group ${SQ}test${SQ} has unstable threshold before stable one 231 EOF 232 233 test_cmp expect err 234 ' 235 236 test_expect_success 'pseudo-merge pattern with capture groups' ' 237 git init pseudo-merge-captures && 238 ( 239 cd pseudo-merge-captures && 240 241 test_commit_bulk 128 && 242 tag_everything && 243 244 for r in $(test_seq 8) 245 do 246 test_commit_bulk 16 && 247 248 git rev-list HEAD~16.. >in && 249 sed "s|\(.*\)|create refs/remotes/$r/tags/\1 \1|" in >refs && 250 git update-ref --stdin refs && 259 260 test_pseudo_merges >merges && 261 for m in $(test_seq 0 $(($(wc -l oids && 264 grep -f oids refs | 265 sed -n "s|refs/remotes/\([0-9][0-9]*\)/|\1|p" && 266 sort -u || return 1 267 done >remotes && 268 269 test $(wc -l merges && 297 test_line_count = 2 merges && 298 299 test_pseudo_merge_commits 0 >commits-0.raw && 300 test_pseudo_merge_commits 1 >commits-1.raw && 301 302 sort commits-0.raw >commits-0 && 303 sort commits-1.raw >commits-1 && 304 305 comm -12 commits-0 commits-1 >overlap && 306 307 test_line_count -gt 0 overlap 308 ) 309 ' 310 311 test_expect_success 'pseudo-merge overlap traversal' ' 312 ( 313 cd pseudo-merge-overlap && 314 315 : >trace2.txt && 316 GIT_TRACE2_EVENT=$PWD/trace2.txt \ 317 git rev-list --count --all --objects --use-bitmap-index >actual && 318 git rev-list --count --all --objects >expect && 319 320 test_pseudo_merges_satisfied 2 trace2.txt && 333 GIT_TRACE2_EVENT=$PWD/trace2.txt \ 334 git rev-list --count --all --objects --use-bitmap-index >actual && 335 git rev-list --count --all --objects >expect && 336 337 test_pseudo_merges_satisfied 2 merges && 369 test_line_count = 2 merges && 370 371 test_pseudo_merge_commits 0 >stable-oids.before && 372 test_pseudo_merge_commits 1 >unstable-oids.before && 373 374 : >trace2.txt && 375 GIT_TRACE2_EVENT=$PWD/trace2.txt git \ 376 -c bitmapPseudoMerge.test.pattern="refs/tags/" \ 377 -c bitmapPseudoMerge.test.maxMerges=2 \ 378 -c bitmapPseudoMerge.test.threshold=now \ 379 -c bitmapPseudoMerge.test.stableThreshold=$(($unstable - 1)) \ 380 -c bitmapPseudoMerge.test.stableSize=512 \ 381 repack -adb && 382 383 test_pseudo_merges_reused 1 merges && 386 test_line_count = 3 merges && 387 388 test_pseudo_merge_commits 0 >stable-oids.after && 389 for i in 1 2 390 do 391 test_pseudo_merge_commits $i || return 1 392 done >unstable-oids.after && 393 394 sort -u expect && 395 sort -u actual && 396 test_cmp expect actual && 397 398 sort -u expect && 399 sort -u actual && 400 test_cmp expect actual 401 ) 402 ' 403 404 test_expect_success 'empty pseudo-merge group' ' 405 git init pseudo-merge-empty-group && 406 ( 407 cd pseudo-merge-empty-group && 408 409 # Ensure that a pseudo-merge group with no unstable 410 # commits does not generate an empty pseudo-merge 411 # bitmap. 412 git config bitmapPseudoMerge.empty.pattern refs/ && 413 414 test_commit base && 415 git repack -adb && 416 417 test-tool bitmap dump-pseudo-merges >merges && 418 test_line_count = 1 merges && 419 420 test 0 -eq "$(grep -c commits=0 pseudo-merges && 449 test_line_count = 1 pseudo-merges && 450 451 git rev-parse A >expect && 452 453 test-tool bitmap list-commits >actual && 454 test_cmp expect actual && 455 test-tool bitmap dump-pseudo-merge-commits 0 >actual && 456 test_cmp expect actual 457 ) 458 ' 459 460 test_expect_success 'use pseudo-merge in boundary traversal' ' 461 git init pseudo-merge-boundary-traversal && 462 ( 463 cd pseudo-merge-boundary-traversal && 464 465 git config bitmapPseudoMerge.test.pattern refs/ && 466 git config pack.useBitmapBoundaryTraversal true && 467 468 test_commit A && 469 git repack -adb && 470 test_commit B && 471 472 nr=$(git rev-list --count --use-bitmap-index HEAD~1..HEAD) && 473 test 1 -eq "$nr" 474 ) 475 ' 476 477 test_expect_success 'apply pseudo-merges during fill-in traversal' ' 478 test_when_finished "rm -fr pseudo-merge-fill-in-traversal" && 479 git init pseudo-merge-fill-in-traversal && 480 ( 481 cd pseudo-merge-fill-in-traversal && 482 483 git config bitmapPseudoMerge.test.pattern refs/tags/ && 484 git config bitmapPseudoMerge.test.maxMerges 1 && 485 git config bitmapPseudoMerge.test.stableThreshold never && 486 487 test_commit_bulk 64 && 488 tag_everything && 489 git repack -ad && 490 491 pack=$(ls .git/objects/pack/pack-*.pack) && 492 git rev-parse HEAD~63 >in && 493 test-tool bitmap write "$(basename $pack)" merges && 496 test_line_count = 1 merges && 497 498 test_commit stale && 499 500 git rev-list --count --objects HEAD >expect && 501 502 : >trace2.txt && 503 GIT_TRACE2_EVENT=$PWD/trace2.txt \ 504 git rev-list --count --objects --use-bitmap-index HEAD >actual && 505 test_pseudo_merges_satisfied 1 in && 526 while read oid 527 do 528 echo "create refs/group-$side/$oid $oid" || return 1 529 done in && 546 test-tool bitmap write "$(basename $pack)" merges && 549 test_line_count = 2 merges && 550 551 test_commit stale && 552 553 git rev-list --count --objects HEAD >expect && 554 555 : >trace2.txt && 556 GIT_TRACE2_EVENT=$PWD/trace2.txt \ 557 git rev-list --count --objects --use-bitmap-index HEAD >actual && 558 test_pseudo_merges_satisfied 2 in && 589 test-tool bitmap write "$(basename $pack)" merges && 592 test_line_count = 2 merges && 593 594 test_commit stale && 595 596 git rev-list --count --objects HEAD >expect && 597 598 : >trace2.txt && 599 GIT_TRACE2_EVENT=$PWD/trace2.txt \ 600 git rev-list --count --objects --use-bitmap-index HEAD >actual && 601 test_pseudo_merges_satisfied 2 in && 646 GIT_TEST_DATE_NOW=$test_tick \ 647 test-tool bitmap write "$(basename $pack)" merges && 650 test_line_count = 1 merges 651 ) 652 ' 653 654 test_expect_success 'sampleRate=0 does not cause division by zero' ' 655 test_when_finished "rm -fr pseudo-merge-sample-rate-zero" && 656 git init pseudo-merge-sample-rate-zero && 657 ( 658 cd pseudo-merge-sample-rate-zero && 659 660 test_commit_bulk 64 && 661 tag_everything && 662 git repack -ad && 663 664 pack="$(ls .git/objects/pack/pack-*.pack)" && 665 666 git config bitmapPseudoMerge.test.pattern "refs/tags/" && 667 git config bitmapPseudoMerge.test.maxMerges 1 && 668 git config bitmapPseudoMerge.test.sampleRate 0 && 669 git config bitmapPseudoMerge.test.threshold now && 670 git config bitmapPseudoMerge.test.stableThreshold never && 671 672 git rev-parse HEAD~63 >in && 673 test-tool bitmap write "$(basename $pack)" in && 699 test-tool bitmap write "$(basename $pack)" merges && 702 test_line_count = 1 merges 703 ) 704 ' 705 706 test_done