Skip to content

Commit 0665185

Browse files
committed
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>
1 parent 8d001e4 commit 0665185

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
@@ -449,4 +449,36 @@ test_expect_success 'expire removes repacked packs' '
449449
)
450450
'
451451

452+
test_expect_success 'expire works when adding new packs' '
453+
(
454+
cd dup &&
455+
git pack-objects --revs .git/objects/pack/pack-combined <<-EOF &&
456+
refs/heads/A
457+
^refs/heads/B
458+
EOF
459+
git pack-objects --revs .git/objects/pack/pack-combined <<-EOF &&
460+
refs/heads/B
461+
^refs/heads/C
462+
EOF
463+
git pack-objects --revs .git/objects/pack/pack-combined <<-EOF &&
464+
refs/heads/C
465+
^refs/heads/D
466+
EOF
467+
git multi-pack-index write &&
468+
git pack-objects --revs .git/objects/pack/a-pack <<-EOF &&
469+
refs/heads/D
470+
^refs/heads/E
471+
EOF
472+
git multi-pack-index write &&
473+
git pack-objects --revs .git/objects/pack/z-pack <<-EOF &&
474+
refs/heads/E
475+
EOF
476+
git multi-pack-index expire &&
477+
ls .git/objects/pack/ | grep idx >expect &&
478+
test-tool read-midx .git/objects | grep idx >actual &&
479+
test_cmp expect actual &&
480+
git multi-pack-index verify
481+
)
482+
'
483+
452484
test_done

0 commit comments

Comments
 (0)