Skip to content

Commit 13d746a

Browse files
ttaylorrgitster
authored andcommitted
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 <[email protected]> Signed-off-by: Taylor Blau <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent dab3247 commit 13d746a

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

builtin/repack.c

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -356,21 +356,19 @@ static void split_pack_geometry(struct pack_geometry *geometry, int factor)
356356
return;
357357
}
358358

359-
split = geometry->pack_nr - 1;
360-
361359
/*
362360
* First, count the number of packs (in descending order of size) which
363361
* already form a geometric progression.
364362
*/
365363
for (i = geometry->pack_nr - 1; i > 0; i--) {
366364
struct packed_git *ours = geometry->pack[i];
367365
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))
371367
break;
372368
}
373369

370+
split = i;
371+
374372
if (split) {
375373
/*
376374
* Move the split one to the right, since the top element in the

0 commit comments

Comments
 (0)