t5304: test cleaning pack garbage

Pack garbage, noticeably stale .idx files, can be cleaned up during a garbage collection. This tests to ensure such garbage is properly cleaned up. Note that the prior test for checking pack garbage with count-objects left some stale garbage after the test exited. This has also been corrected. Signed-off-by: Doug Kelly <dougk.ff7@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Doug Kelly committed Nov 3, 2015 at 21:05 UTC e6d65c9a47a0f245614d34246fe28782a6d2209b
1 file changed +21
t/t5304-prune.sh
+21
@@ -219,6 +219,7 @@ test_expect_success 'gc: prune old objects after local clone' '
219
220 test_expect_success 'garbage report in count-objects -v' '
221 test_when_finished "rm -f .git/objects/pack/fake*" &&
222 + test_when_finished "rm -f .git/objects/pack/foo*" &&
223 : >.git/objects/pack/foo &&
224 : >.git/objects/pack/foo.bar &&
225 : >.git/objects/pack/foo.keep &&
@@ -244,6 +245,26 @@ EOF
245 test_cmp expected actual
246 '
247
248 +test_expect_failure 'clean pack garbage with gc' '
249 + test_when_finished "rm -f .git/objects/pack/fake*" &&
250 + test_when_finished "rm -f .git/objects/pack/foo*" &&
251 + : >.git/objects/pack/foo.keep &&
252 + : >.git/objects/pack/foo.pack &&
253 + : >.git/objects/pack/fake.idx &&
254 + : >.git/objects/pack/fake2.keep &&
255 + : >.git/objects/pack/fake2.idx &&
256 + : >.git/objects/pack/fake3.keep &&
257 + git gc &&
258 + git count-objects -v 2>stderr &&
259 + grep "^warning:" stderr | sort >actual &&
260 + cat >expected <<\EOF &&
261 +warning: no corresponding .idx or .pack: .git/objects/pack/fake3.keep
262 +warning: no corresponding .idx: .git/objects/pack/foo.keep
263 +warning: no corresponding .idx: .git/objects/pack/foo.pack
264 +EOF
265 + test_cmp expected actual
266 +'
267 +
268 test_expect_success 'prune .git/shallow' '
269 SHA1=`echo hi|git commit-tree HEAD^{tree}` &&
270 echo $SHA1 >.git/shallow &&