Skip to content

Commit d9f7721

Browse files
ttaylorrgitster
authored andcommitted
midx.c: avoid cruft packs with repack --batch-size=0
The `repack` sub-command of the `git multi-pack-index` builtin creates a new pack aggregating smaller packs contained in the MIDX up to some given `--batch-size`. When `--batch-size=0`, this instructs the MIDX builtin to repack everything contained in the MIDX into a single pack. In similar spirit as a previous commit, it is undesirable to repack the contents of a cruft pack in this step. Teach `repack` to ignore any cruft pack(s) when `--batch-size=0` for the same reason(s). (The case of a non-zero `--batch-size` will be handled in a subsequent commit). Signed-off-by: Taylor Blau <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 757d457 commit d9f7721

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

midx.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1895,6 +1895,8 @@ static int fill_included_packs_all(struct repository *r,
18951895
continue;
18961896
if (!pack_kept_objects && m->packs[i]->pack_keep)
18971897
continue;
1898+
if (m->packs[i]->is_cruft)
1899+
continue;
18981900

18991901
include_pack[i] = 1;
19001902
count++;

t/t5319-multi-pack-index.sh

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -784,6 +784,29 @@ test_expect_success 'repack creates a new pack' '
784784
)
785785
'
786786

787+
test_expect_success 'repack (all) ignores cruft pack' '
788+
git init repo &&
789+
test_when_finished "rm -fr repo" &&
790+
(
791+
cd repo &&
792+
793+
test_commit base &&
794+
test_commit --no-tag unreachable &&
795+
796+
git reset --hard base &&
797+
git reflog expire --all --expire=all &&
798+
git repack --cruft -d &&
799+
800+
git multi-pack-index write &&
801+
802+
find $objdir/pack | sort >before &&
803+
git multi-pack-index repack --batch-size=0 &&
804+
find $objdir/pack | sort >after &&
805+
806+
test_cmp before after
807+
)
808+
'
809+
787810
test_expect_success 'expire removes repacked packs' '
788811
(
789812
cd dup &&

0 commit comments

Comments
 (0)