Skip to content

Commit 10bfa3f

Browse files
derrickstoleegitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent d274331 commit 10bfa3f

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
@@ -510,4 +510,22 @@ test_expect_success 'expire works when adding new packs' '
510510
)
511511
'
512512

513+
test_expect_success 'expire respects .keep files' '
514+
(
515+
cd dup &&
516+
git pack-objects --revs .git/objects/pack/pack-all <<-EOF &&
517+
refs/heads/A
518+
EOF
519+
git multi-pack-index write &&
520+
PACKA=$(ls .git/objects/pack/a-pack*\.pack | sed s/\.pack\$//) &&
521+
touch $PACKA.keep &&
522+
git multi-pack-index expire &&
523+
ls -S .git/objects/pack/a-pack* | grep $PACKA >a-pack-files &&
524+
test_line_count = 3 a-pack-files &&
525+
test-tool read-midx .git/objects | grep idx >midx-list &&
526+
test_line_count = 2 midx-list
527+
)
528+
'
529+
530+
513531
test_done

0 commit comments

Comments
 (0)