Skip to content

Commit e6d65c9

Browse files
vangdfanggitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 0a489b0 commit e6d65c9

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

t/t5304-prune.sh

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,7 @@ test_expect_success 'gc: prune old objects after local clone' '
219219

220220
test_expect_success 'garbage report in count-objects -v' '
221221
test_when_finished "rm -f .git/objects/pack/fake*" &&
222+
test_when_finished "rm -f .git/objects/pack/foo*" &&
222223
: >.git/objects/pack/foo &&
223224
: >.git/objects/pack/foo.bar &&
224225
: >.git/objects/pack/foo.keep &&
@@ -244,6 +245,26 @@ EOF
244245
test_cmp expected actual
245246
'
246247

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+
247268
test_expect_success 'prune .git/shallow' '
248269
SHA1=`echo hi|git commit-tree HEAD^{tree}` &&
249270
echo $SHA1 >.git/shallow &&

0 commit comments

Comments
 (0)