Skip to content

Commit d274331

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

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

t/t5319-multi-pack-index.sh

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -478,4 +478,36 @@ test_expect_success 'expire removes repacked packs' '
478478
)
479479
'
480480

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+
481513
test_done

0 commit comments

Comments
 (0)