builtin/repack.c: assign pack split later

To determine the where to place the split when repacking with the '--geometric' option, split_pack_geometry() assigns the "split" variable and then decrements it in a loop. It would be equivalent (and more readable) to assign the split to the loop position after exiting the loop, so do that instead. Suggested-by: Junio C Hamano <gitster@pobox.com> Signed-off-by: Taylor Blau <me@ttaylorr.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Taylor Blau committed Mar 5, 2021 at 10:21 UTC 13d746a303592068826824b30c47941fb328c8a7
1 file changed +3 -5
builtin/repack.c
+3 -5
@@ -356,8 +356,6 @@ static void split_pack_geometry(struct pack_geometry *geometry, int factor)
356 return;
357 }
358
359 - split = geometry->pack_nr - 1;
360 -
359 /*
360 * First, count the number of packs (in descending order of size) which
361 * already form a geometric progression.
@@ -365,12 +363,12 @@ static void split_pack_geometry(struct pack_geometry *geometry, int factor)
363 for (i = geometry->pack_nr - 1; i > 0; i--) {
364 struct packed_git *ours = geometry->pack[i];
365 struct packed_git *prev = geometry->pack[i - 1];
368 - if (geometry_pack_weight(ours) >= factor * geometry_pack_weight(prev))
369 - split--;
370 - else
366 + if (geometry_pack_weight(ours) < factor * geometry_pack_weight(prev))
367 break;
368 }
369
370 + split = i;
371 +
372 if (split) {
373 /*
374 * Move the split one to the right, since the top element in the