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/t1409-avoid-packing-refs.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 / t1409-avoid-packing-refs.sh` 124 lines ยท 3653 bytes Raw Blame History 1 #!/bin/sh 2 3 test_description='avoid rewriting packed-refs unnecessarily' 4 5 . ./test-lib.sh 6 7 if test_have_prereq !REFFILES 8 then 9 skip_all='skipping files-backend specific pack-refs tests' 10 test_done 11 fi 12 13 # Add an identifying mark to the packed-refs file header line. This 14 # shouldn't upset readers, and it should be omitted if the file is 15 # ever rewritten. 16 mark_packed_refs () { 17 sed -e "s/^\(#.*\)/\1 t1409 /" .git/packed-refs >.git/packed-refs.new && 18 mv .git/packed-refs.new .git/packed-refs 19 } 20 21 # Verify that the packed-refs file is still marked. 22 check_packed_refs_marked () { 23 grep -q '^#.* t1409 ' .git/packed-refs 24 } 25 26 test_expect_success 'setup' ' 27 git commit --allow-empty -m "Commit A" && 28 A=$(git rev-parse HEAD) && 29 git commit --allow-empty -m "Commit B" && 30 B=$(git rev-parse HEAD) && 31 git commit --allow-empty -m "Commit C" && 32 C=$(git rev-parse HEAD) 33 ' 34 35 test_expect_success 'do not create packed-refs file gratuitously' ' 36 test_path_is_missing .git/packed-refs && 37 git update-ref refs/heads/foo $A && 38 test_path_is_missing .git/packed-refs && 39 git update-ref refs/heads/foo $B && 40 test_path_is_missing .git/packed-refs && 41 git update-ref refs/heads/foo $C $B && 42 test_path_is_missing .git/packed-refs && 43 git update-ref -d refs/heads/foo && 44 test_path_is_missing .git/packed-refs 45 ' 46 47 test_expect_success 'check that marking the packed-refs file works' ' 48 git for-each-ref >expected && 49 git pack-refs --all && 50 mark_packed_refs && 51 check_packed_refs_marked && 52 git for-each-ref >actual && 53 test_cmp expected actual && 54 git pack-refs --all && 55 ! check_packed_refs_marked && 56 git for-each-ref >actual2 && 57 test_cmp expected actual2 58 ' 59 60 test_expect_success 'leave packed-refs untouched on update of packed' ' 61 git update-ref refs/heads/packed-update $A && 62 git pack-refs --all && 63 mark_packed_refs && 64 git update-ref refs/heads/packed-update $B && 65 check_packed_refs_marked 66 ' 67 68 test_expect_success 'leave packed-refs untouched on checked update of packed' ' 69 git update-ref refs/heads/packed-checked-update $A && 70 git pack-refs --all && 71 mark_packed_refs && 72 git update-ref refs/heads/packed-checked-update $B $A && 73 check_packed_refs_marked 74 ' 75 76 test_expect_success 'leave packed-refs untouched on verify of packed' ' 77 git update-ref refs/heads/packed-verify $A && 78 git pack-refs --all && 79 mark_packed_refs && 80 echo "verify refs/heads/packed-verify $A" | git update-ref --stdin && 81 check_packed_refs_marked 82 ' 83 84 test_expect_success 'touch packed-refs on delete of packed' ' 85 git update-ref refs/heads/packed-delete $A && 86 git pack-refs --all && 87 mark_packed_refs && 88 git update-ref -d refs/heads/packed-delete && 89 ! check_packed_refs_marked 90 ' 91 92 test_expect_success 'leave packed-refs untouched on update of loose' ' 93 git pack-refs --all && 94 git update-ref refs/heads/loose-update $A && 95 mark_packed_refs && 96 git update-ref refs/heads/loose-update $B && 97 check_packed_refs_marked 98 ' 99 100 test_expect_success 'leave packed-refs untouched on checked update of loose' ' 101 git pack-refs --all && 102 git update-ref refs/heads/loose-checked-update $A && 103 mark_packed_refs && 104 git update-ref refs/heads/loose-checked-update $B $A && 105 check_packed_refs_marked 106 ' 107 108 test_expect_success 'leave packed-refs untouched on verify of loose' ' 109 git pack-refs --all && 110 git update-ref refs/heads/loose-verify $A && 111 mark_packed_refs && 112 echo "verify refs/heads/loose-verify $A" | git update-ref --stdin && 113 check_packed_refs_marked 114 ' 115 116 test_expect_success 'leave packed-refs untouched on delete of loose' ' 117 git pack-refs --all && 118 git update-ref refs/heads/loose-delete $A && 119 mark_packed_refs && 120 git update-ref -d refs/heads/loose-delete && 121 check_packed_refs_marked 122 ' 123 124 test_done