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 <me@ttaylorr.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Taylor Blau committed
Sep 19, 2022 at 21:55 UTC
d9f772145069fc0e2aa56a76229e001e0b47248e
2 files changed
+25
midx.c
+2
@@ -1895,6 +1895,8 @@ static int fill_included_packs_all(struct repository *r,
1895
continue;
1896
if (!pack_kept_objects && m->packs[i]->pack_keep)
1897
continue;
1898
+ if (m->packs[i]->is_cruft)
1899
+ continue;
1900
1901
include_pack[i] = 1;
1902
count++;
t/t5319-multi-pack-index.sh
+23
@@ -784,6 +784,29 @@ test_expect_success 'repack creates a new pack' '
784
)
785
'
786
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
+
810
test_expect_success 'expire removes repacked packs' '
811
(
812
cd dup &&