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> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Derrick Stolee committed
Jun 10, 2019 at 16:35 UTC
10bfa3f7f58406a5799267e4844fcd3f9ec16097
1 file changed
+18
t/t5319-multi-pack-index.sh
+18
@@ -510,4 +510,22 @@ test_expect_success 'expire works when adding new packs' '
510
)
511
'
512
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
+
531
test_done