]> Kevux Git Server - rit/commit
builtin/repack.c: do not repack single packs with --geometric
authorTaylor Blau <me@ttaylorr.com>
Fri, 5 Mar 2021 15:21:37 +0000 (10:21 -0500)
committerJunio C Hamano <gitster@pobox.com>
Fri, 5 Mar 2021 19:33:52 +0000 (11:33 -0800)
commitf25e33c1566fecb097a460f0649ac1a20c418843
treed64cdd765f6ea5596408c37bac984fdd00fd56a9
parent0fabafd0b948bfc1c07db73494863d581c7f5d04
builtin/repack.c: do not repack single packs with --geometric

In 0fabafd0b9 (builtin/repack.c: add '--geometric' option, 2021-02-22),
the 'git repack --geometric' code aborts early when there is zero or one
pack.

When there are no packs, this code does the right thing by placing the
split at "0". But when there is exactly one pack, the split is placed at
"1", which means that "git repack --geometric" (with any factor)
repacks all of the objects in a single pack.

This is wasteful, and the remaining code in split_pack_geometry() does
the right thing (not repacking the objects in a single pack) even when
only one pack is present.

Loosen the guard to only stop when there aren't any packs, and let the
rest of the code do the right thing. Add a test to ensure that this is
the case.

Noticed-by: Junio C Hamano <gitster@pobox.com>
Signed-off-by: Taylor Blau <me@ttaylorr.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/repack.c
t/t7703-repack-geometric.sh