multi-pack-index: test expire while adding packs

During development of the multi-pack-index expire subcommand, a version went out that improperly computed the pack order if a new pack was introduced while other packs were being removed. Part of the subtlety of the bug involved the new pack being placed before other packs that already existed in the multi-pack-index. Add a test to t5319-multi-pack-index.sh that catches this issue. The test adds new packs that cause another pack to be expired, and creates new packs that are lexicographically sorted before and after the existing packs. 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 d2743315d4d05d2fd4dc83afa2009c0615a94527
1 file changed +32
t/t5319-multi-pack-index.sh
+32
@@ -478,4 +478,36 @@ test_expect_success 'expire removes repacked packs' '
478 )
479 '
480
481 +test_expect_success 'expire works when adding new packs' '
482 + (
483 + cd dup &&
484 + git pack-objects --revs .git/objects/pack/pack-combined <<-EOF &&
485 + refs/heads/A
486 + ^refs/heads/B
487 + EOF
488 + git pack-objects --revs .git/objects/pack/pack-combined <<-EOF &&
489 + refs/heads/B
490 + ^refs/heads/C
491 + EOF
492 + git pack-objects --revs .git/objects/pack/pack-combined <<-EOF &&
493 + refs/heads/C
494 + ^refs/heads/D
495 + EOF
496 + git multi-pack-index write &&
497 + git pack-objects --revs .git/objects/pack/a-pack <<-EOF &&
498 + refs/heads/D
499 + ^refs/heads/E
500 + EOF
501 + git multi-pack-index write &&
502 + git pack-objects --revs .git/objects/pack/z-pack <<-EOF &&
503 + refs/heads/E
504 + EOF
505 + git multi-pack-index expire &&
506 + ls .git/objects/pack/ | grep idx >expect &&
507 + test-tool read-midx .git/objects | grep idx >actual &&
508 + test_cmp expect actual &&
509 + git multi-pack-index verify
510 + )
511 +'
512 +
513 test_done