3 test_description
='avoid rewriting packed-refs unnecessarily'
7 # Add an identifying mark to the packed-refs file header line. This
8 # shouldn't upset readers, and it should be omitted if the file is
11 sed -e "s/^\(#.*\)/\1 t1409 /" .git
/packed-refs
>.git
/packed-refs.new
&&
12 mv .git
/packed-refs.new .git
/packed-refs
15 # Verify that the packed-refs file is still marked.
16 check_packed_refs_marked
() {
17 grep -q '^#.* t1409 ' .git
/packed-refs
20 test_expect_success
'setup' '
21 git commit --allow-empty -m "Commit A" &&
22 A=$(git rev-parse HEAD) &&
23 git commit --allow-empty -m "Commit B" &&
24 B=$(git rev-parse HEAD) &&
25 git commit --allow-empty -m "Commit C" &&
26 C=$(git rev-parse HEAD)
29 test_expect_success
'do not create packed-refs file gratuitously' '
30 test_path_is_missing .git/packed-refs &&
31 git update-ref refs/heads/foo $A &&
32 test_path_is_missing .git/packed-refs &&
33 git update-ref refs/heads/foo $B &&
34 test_path_is_missing .git/packed-refs &&
35 git update-ref refs/heads/foo $C $B &&
36 test_path_is_missing .git/packed-refs &&
37 git update-ref -d refs/heads/foo &&
38 test_path_is_missing .git/packed-refs
41 test_expect_success
'check that marking the packed-refs file works' '
42 git for-each-ref >expected &&
43 git pack-refs --all &&
45 check_packed_refs_marked &&
46 git for-each-ref >actual &&
47 test_cmp expected actual &&
48 git pack-refs --all &&
49 ! check_packed_refs_marked &&
50 git for-each-ref >actual2 &&
51 test_cmp expected actual2
54 test_expect_success
'leave packed-refs untouched on update of packed' '
55 git update-ref refs/heads/packed-update $A &&
56 git pack-refs --all &&
58 git update-ref refs/heads/packed-update $B &&
59 check_packed_refs_marked
62 test_expect_success
'leave packed-refs untouched on checked update of packed' '
63 git update-ref refs/heads/packed-checked-update $A &&
64 git pack-refs --all &&
66 git update-ref refs/heads/packed-checked-update $B $A &&
67 check_packed_refs_marked
70 test_expect_success
'leave packed-refs untouched on verify of packed' '
71 git update-ref refs/heads/packed-verify $A &&
72 git pack-refs --all &&
74 echo "verify refs/heads/packed-verify $A" | git update-ref --stdin &&
75 check_packed_refs_marked
78 test_expect_success
'touch packed-refs on delete of packed' '
79 git update-ref refs/heads/packed-delete $A &&
80 git pack-refs --all &&
82 git update-ref -d refs/heads/packed-delete &&
83 ! check_packed_refs_marked
86 test_expect_success
'leave packed-refs untouched on update of loose' '
87 git pack-refs --all &&
88 git update-ref refs/heads/loose-update $A &&
90 git update-ref refs/heads/loose-update $B &&
91 check_packed_refs_marked
94 test_expect_success
'leave packed-refs untouched on checked update of loose' '
95 git pack-refs --all &&
96 git update-ref refs/heads/loose-checked-update $A &&
98 git update-ref refs/heads/loose-checked-update $B $A &&
99 check_packed_refs_marked
102 test_expect_success
'leave packed-refs untouched on verify of loose' '
103 git pack-refs --all &&
104 git update-ref refs/heads/loose-verify $A &&
106 echo "verify refs/heads/loose-verify $A" | git update-ref --stdin &&
107 check_packed_refs_marked
110 test_expect_success
'leave packed-refs untouched on delete of loose' '
111 git pack-refs --all &&
112 git update-ref refs/heads/loose-delete $A &&
114 git update-ref -d refs/heads/loose-delete &&
115 check_packed_refs_marked