3 test_description
='avoid rewriting packed-refs unnecessarily'
5 TEST_PASSES_SANITIZE_LEAK
=true
8 if test_have_prereq
!REFFILES
10 skip_all
='skipping files-backend specific pack-refs tests'
14 # Add an identifying mark to the packed-refs file header line. This
15 # shouldn't upset readers, and it should be omitted if the file is
18 sed -e "s/^\(#.*\)/\1 t1409 /" .git
/packed-refs
>.git
/packed-refs.new
&&
19 mv .git
/packed-refs.new .git
/packed-refs
22 # Verify that the packed-refs file is still marked.
23 check_packed_refs_marked
() {
24 grep -q '^#.* t1409 ' .git
/packed-refs
27 test_expect_success
'setup' '
28 git commit --allow-empty -m "Commit A" &&
29 A=$(git rev-parse HEAD) &&
30 git commit --allow-empty -m "Commit B" &&
31 B=$(git rev-parse HEAD) &&
32 git commit --allow-empty -m "Commit C" &&
33 C=$(git rev-parse HEAD)
36 test_expect_success
'do not create packed-refs file gratuitously' '
37 test_path_is_missing .git/packed-refs &&
38 git update-ref refs/heads/foo $A &&
39 test_path_is_missing .git/packed-refs &&
40 git update-ref refs/heads/foo $B &&
41 test_path_is_missing .git/packed-refs &&
42 git update-ref refs/heads/foo $C $B &&
43 test_path_is_missing .git/packed-refs &&
44 git update-ref -d refs/heads/foo &&
45 test_path_is_missing .git/packed-refs
48 test_expect_success
'check that marking the packed-refs file works' '
49 git for-each-ref >expected &&
50 git pack-refs --all &&
52 check_packed_refs_marked &&
53 git for-each-ref >actual &&
54 test_cmp expected actual &&
55 git pack-refs --all &&
56 ! check_packed_refs_marked &&
57 git for-each-ref >actual2 &&
58 test_cmp expected actual2
61 test_expect_success
'leave packed-refs untouched on update of packed' '
62 git update-ref refs/heads/packed-update $A &&
63 git pack-refs --all &&
65 git update-ref refs/heads/packed-update $B &&
66 check_packed_refs_marked
69 test_expect_success
'leave packed-refs untouched on checked update of packed' '
70 git update-ref refs/heads/packed-checked-update $A &&
71 git pack-refs --all &&
73 git update-ref refs/heads/packed-checked-update $B $A &&
74 check_packed_refs_marked
77 test_expect_success
'leave packed-refs untouched on verify of packed' '
78 git update-ref refs/heads/packed-verify $A &&
79 git pack-refs --all &&
81 echo "verify refs/heads/packed-verify $A" | git update-ref --stdin &&
82 check_packed_refs_marked
85 test_expect_success
'touch packed-refs on delete of packed' '
86 git update-ref refs/heads/packed-delete $A &&
87 git pack-refs --all &&
89 git update-ref -d refs/heads/packed-delete &&
90 ! check_packed_refs_marked
93 test_expect_success
'leave packed-refs untouched on update of loose' '
94 git pack-refs --all &&
95 git update-ref refs/heads/loose-update $A &&
97 git update-ref refs/heads/loose-update $B &&
98 check_packed_refs_marked
101 test_expect_success
'leave packed-refs untouched on checked update of loose' '
102 git pack-refs --all &&
103 git update-ref refs/heads/loose-checked-update $A &&
105 git update-ref refs/heads/loose-checked-update $B $A &&
106 check_packed_refs_marked
109 test_expect_success
'leave packed-refs untouched on verify of loose' '
110 git pack-refs --all &&
111 git update-ref refs/heads/loose-verify $A &&
113 echo "verify refs/heads/loose-verify $A" | git update-ref --stdin &&
114 check_packed_refs_marked
117 test_expect_success
'leave packed-refs untouched on delete of loose' '
118 git pack-refs --all &&
119 git update-ref refs/heads/loose-delete $A &&
121 git update-ref -d refs/heads/loose-delete &&
122 check_packed_refs_marked