Skip to content

Commit 481b088

Browse files
committed
midx: add test that 'expire' respects .keep files
The 'git multi-pack-index expire' subcommand may delete packs that are not needed from the perspective of the multi-pack-index. If a pack has a .keep file, then we should not delete that pack. Add a test that ensures we preserve a pack that would otherwise be expired. First, create a new pack that contains every object in the repo, then add it to the multi-pack-index. Then create a .keep file for a pack starting with "a-pack" that was added in the previous test. Finally, expire and verify that the pack remains and the other packs were expired. Signed-off-by: Derrick Stolee <dstolee@microsoft.com>
1 parent b1c6892 commit 481b088

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

t/t5319-multi-pack-index.sh

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -495,4 +495,22 @@ test_expect_success 'expire works when adding new packs' '
495495
)
496496
'
497497

498+
test_expect_success 'expire respects .keep files' '
499+
(
500+
cd dup &&
501+
git pack-objects --revs .git/objects/pack/pack-all <<-EOF &&
502+
refs/heads/A
503+
EOF
504+
git multi-pack-index write &&
505+
PACKA=$(ls .git/objects/pack/a-pack*\.pack | sed s/\.pack\$//) &&
506+
touch $PACKA.keep &&
507+
git multi-pack-index expire &&
508+
ls -S .git/objects/pack/a-pack* | grep $PACKA >a-pack-files &&
509+
test_line_count = 3 a-pack-files &&
510+
test-tool read-midx .git/objects | grep idx >midx-list &&
511+
test_line_count = 2 midx-list
512+
)
513+
'
514+
515+
498516
test_done

0 commit comments

Comments
 (0)