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/t9301-fast-import-notes.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 / t9301-fast-import-notes.sh` 727 lines ยท 14572 bytes Raw Blame History 1 #!/bin/sh 2 # 3 # Copyright (c) 2009 Johan Herland 4 # 5 6 test_description='test git fast-import of notes objects' 7 GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main 8 export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME 9 10 . ./test-lib.sh 11 12 13 test_tick 14 cat >input < $GIT_COMMITTER_DATE 17 data < $GIT_COMMITTER_DATE 38 data < $GIT_COMMITTER_DATE 54 data < $GIT_COMMITTER_DATE 65 data <input < $GIT_COMMITTER_DATE 91 data <expect < actual && 120 test_cmp expect actual 121 122 ' 123 124 test_tick 125 cat >input < $GIT_COMMITTER_DATE 129 data <expect < actual && 161 test_cmp expect actual 162 163 ' 164 165 test_tick 166 cat >input < $GIT_COMMITTER_DATE 169 data <expect < actual && 211 test_cmp expect actual 212 213 ' 214 215 test_tick 216 cat >input < $GIT_COMMITTER_DATE 219 data <expect < actual && 285 test_cmp expect actual 286 287 ' 288 289 test_tick 290 cat >input < $GIT_COMMITTER_DATE 293 data <expect < actual && 313 test_cmp expect actual 314 315 ' 316 317 test_tick 318 cat >input < $GIT_COMMITTER_DATE 321 data <expect < actual && 361 test_cmp expect actual 362 363 ' 364 365 # Write fast-import commands to create the given number of commits 366 fast_import_commits () { 367 my_ref=$1 368 my_num_commits=$2 369 my_append_to_file=$3 370 my_i=0 371 while test $my_i -lt $my_num_commits 372 do 373 my_i=$(($my_i + 1)) 374 test_tick 375 cat >>"$my_append_to_file" < $GIT_COMMITTER_DATE 379 data <>"$my_append_to_file" < $GIT_COMMITTER_DATE 403 data <>"$my_append_to_file" <>input < $GIT_COMMITTER_DATE 435 data <>expect < actual && 471 test_cmp expect actual 472 473 ' 474 475 test_expect_success 'verify that lots of notes trigger a fanout scheme' ' 476 hexsz=$(test_oid hexsz) && 477 478 # None of the entries in the top-level notes tree should be a full SHA1 479 git ls-tree --name-only refs/notes/many_notes | 480 while read path 481 do 482 if test $(expr length "$path") -ge $hexsz 483 then 484 return 1 485 fi 486 done 487 488 ' 489 490 # Create another notes tree from the one above 491 SP=" " 492 cat >>input < $GIT_COMMITTER_DATE 495 data < $GIT_COMMITTER_DATE 507 data <>expect_non-note1 << EOF 533 This is not a note, but rather a regular file residing in a notes tree 534 EOF 535 536 cat >>expect_non-note2 << EOF 537 Non-note file 538 EOF 539 540 cat >>expect_non-note3 << EOF 541 Another non-note file 542 EOF 543 544 test_expect_success 'verify that non-notes are untouched by a fanout change' ' 545 546 git cat-file -p refs/notes/many_notes:foobar/non-note.txt > actual && 547 test_cmp expect_non-note1 actual && 548 git cat-file -p refs/notes/many_notes:deadbeef > actual && 549 test_cmp expect_non-note2 actual && 550 git cat-file -p refs/notes/many_notes:de/adbeef > actual && 551 test_cmp expect_non-note3 actual 552 553 ' 554 555 # Change the notes for the three top commits 556 test_tick 557 cat >input < $GIT_COMMITTER_DATE 560 data <>input <>expect < actual && 590 test_cmp expect actual 591 592 ' 593 594 test_expect_success 'verify that changing notes respect existing fanout' ' 595 596 # None of the entries in the top-level notes tree should be a full SHA1 597 git ls-tree --name-only refs/notes/many_notes | 598 while read path 599 do 600 if test $(expr length "$path") -ge $hexsz 601 then 602 return 1 603 fi 604 done 605 606 ' 607 608 remaining_notes=10 609 test_tick 610 cat >input < $GIT_COMMITTER_DATE 613 data <>input <>expect <>expect < actual && 648 test_cmp expect actual 649 650 ' 651 652 test_expect_success 'verify that removing notes trigger fanout consolidation' ' 653 # All entries in the top-level notes tree should be a full SHA1 654 git ls-tree --name-only -r refs/notes/many_notes | 655 while read path 656 do 657 # Explicitly ignore the non-note paths 658 test "$path" = "foobar/non-note.txt" && continue 659 test "$path" = "deadbeef" && continue 660 test "$path" = "de/adbeef" && continue 661 662 if test $(expr length "$path") -ne $hexsz 663 then 664 return 1 665 fi 666 done 667 668 ' 669 670 test_expect_success 'verify that non-notes are untouched by a fanout change' ' 671 672 git cat-file -p refs/notes/many_notes:foobar/non-note.txt > actual && 673 test_cmp expect_non-note1 actual && 674 git cat-file -p refs/notes/many_notes:deadbeef > actual && 675 test_cmp expect_non-note2 actual && 676 git cat-file -p refs/notes/many_notes:de/adbeef > actual && 677 test_cmp expect_non-note3 actual 678 679 ' 680 681 682 rm input expect 683 num_notes_refs=10 684 num_commits=16 685 some_commits=8 686 # Create commits 687 fast_import_commits "refs/heads/more_commits" $num_commits input 688 # Create one note per above commit per notes ref 689 i=0 690 while test $i -lt $num_notes_refs 691 do 692 i=$(($i + 1)) 693 fast_import_notes "refs/notes/more_notes_$i" $num_commits input 694 done 695 # Trigger branch reloading in git-fast-import by repeating the note creation 696 i=0 697 while test $i -lt $num_notes_refs 698 do 699 i=$(($i + 1)) 700 fast_import_notes "refs/notes/more_notes_$i" $some_commits input " (2)" 701 done 702 # Finally create the expected output from the notes in refs/notes/more_notes_1 703 i=$num_commits 704 while test $i -gt 0 705 do 706 note_data="note for commit #$i" 707 if test $i -le $some_commits 708 then 709 note_data="$note_data (2)" 710 fi 711 cat >>expect < actual && 723 test_cmp expect actual 724 725 ' 726 727 test_done