t3210: test for spurious error messages for dangling packed refs
A packed reference can be overridden by a loose reference, in which case the packed reference is obsolete and is never used. The object pointed to by such a reference can be garbage collected. Since d66da478f2, this could lead to the emission of a spurious error message: error: refs/heads/master does not point to a valid object! The error is generated by repack_without_ref() if there is an obsolete dangling packed reference in packed-refs when the packed-refs file has to be rewritten due to the deletion of another packed reference. Add a failing test demonstrating this problem and some passing tests of related scenarios. Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Michael Haggerty committed
Apr 22, 2013 at 21:52 UTC
0a0b8d1531feced259223314238aa43cb8ca2ce4
1 file changed
+33
t/t3210-pack-refs.sh
+33
@@ -118,4 +118,37 @@ test_expect_success 'pack, prune and repack' '
118
test_cmp all-of-them again
119
'
120
121
+test_expect_success 'explicit pack-refs with dangling packed reference' '
122
+ git commit --allow-empty -m "soon to be garbage-collected" &&
123
+ git pack-refs --all &&
124
+ git reset --hard HEAD^ &&
125
+ git reflog expire --expire=all --all &&
126
+ git prune --expire=all &&
127
+ git pack-refs --all 2>result &&
128
+ test_cmp /dev/null result
129
+'
130
+
131
+test_expect_success 'delete ref with dangling packed version' '
132
+ git checkout -b lamb &&
133
+ git commit --allow-empty -m "future garbage" &&
134
+ git pack-refs --all &&
135
+ git reset --hard HEAD^ &&
136
+ git checkout master &&
137
+ git reflog expire --expire=all --all &&
138
+ git prune --expire=all &&
139
+ git branch -d lamb 2>result &&
140
+ test_cmp /dev/null result
141
+'
142
+
143
+test_expect_failure 'delete ref while another dangling packed ref' '
144
+ git branch lamb &&
145
+ git commit --allow-empty -m "future garbage" &&
146
+ git pack-refs --all &&
147
+ git reset --hard HEAD^ &&
148
+ git reflog expire --expire=all --all &&
149
+ git prune --expire=all &&
150
+ git branch -d lamb 2>result &&
151
+ test_cmp /dev/null result
152
+'
153
+
154
test_done