builtin/repack.c: inline `remove_redundant_bitmaps()`
After writing a new MIDX, the repack command removes any bitmaps belonging to packs which were written into the MIDX. This is currently done in a separate function outside of `write_midx_included_packs()`, which forces the caller to keep track of the set of packs written into the MIDX. Prepare to no longer require the caller to keep track of such information by inlining the clean-up into `write_midx_included_packs()`. Future commits will make the caller oblivious to the set of packs included in the MIDX altogether. Signed-off-by: Taylor Blau <me@ttaylorr.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Taylor Blau committed
Oct 15, 2025 at 18:29 UTC
337baea7212f0cf1aaa00a885d75098e260a22b0
1 file changed
+8
-7
builtin/repack.c
+8
-7
@@ -331,10 +331,10 @@ static int write_midx_included_packs(struct repack_write_midx_opts *opts)
331
struct string_list_item *item;
332
struct packed_git *preferred = pack_geometry_preferred_pack(opts->geometry);
333
FILE *in;
334
- int ret;
334
+ int ret = 0;
335
336
if (!opts->include->nr)
337
- return 0;
337
+ goto done;
338
339
cmd.in = -1;
340
cmd.git_cmd = 1;
@@ -392,14 +392,18 @@ static int write_midx_included_packs(struct repack_write_midx_opts *opts)
392
393
ret = start_command(&cmd);
394
if (ret)
395
- return ret;
395
+ goto done;
396
397
in = xfdopen(cmd.in, "w");
398
for_each_string_list_item(item, opts->include)
399
fprintf(in, "%s\n", item->string);
400
fclose(in);
401
402
- return finish_command(&cmd);
402
+ ret = finish_command(&cmd);
403
+done:
404
+ if (!ret && opts->write_bitmaps)
405
+ remove_redundant_bitmaps(opts->include, opts->packdir);
406
+ return ret;
407
}
408
409
static int finish_pack_objects_cmd(const struct git_hash_algo *algop,
@@ -1003,9 +1007,6 @@ int cmd_repack(int argc,
1007
1008
ret = write_midx_included_packs(&opts);
1009
1006
- if (!ret && write_bitmaps)
1007
- remove_redundant_bitmaps(&include, opts.packdir);
1008
-
1010
string_list_clear(&include, 0);
1011
1012
if (ret)