From f25e33c1566fecb097a460f0649ac1a20c418843 Mon Sep 17 00:00:00 2001 From: Taylor Blau Date: Fri, 5 Mar 2021 10:21:37 -0500 Subject: 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 Signed-off-by: Taylor Blau Signed-off-by: Junio C Hamano --- builtin/repack.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'builtin/repack.c') diff --git a/builtin/repack.c b/builtin/repack.c index bcf280b10d..4ca2f647b4 100644 --- a/builtin/repack.c +++ b/builtin/repack.c @@ -351,7 +351,7 @@ static void split_pack_geometry(struct pack_geometry *geometry, int factor) uint32_t split; off_t total_size = 0; - if (geometry->pack_nr <= 1) { + if (!geometry->pack_nr) { geometry->split = geometry->pack_nr; return; } -- cgit v1.2.3