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>
main
Taylor Blau 2025-10-15 18:29:05 -04:00 committed by Junio C Hamano
parent 42088e3d4a
commit 337baea721
1 changed files with 8 additions and 7 deletions

View File

@ -331,10 +331,10 @@ static int write_midx_included_packs(struct repack_write_midx_opts *opts)
struct string_list_item *item;
struct packed_git *preferred = pack_geometry_preferred_pack(opts->geometry);
FILE *in;
int ret;
int ret = 0;

if (!opts->include->nr)
return 0;
goto done;

cmd.in = -1;
cmd.git_cmd = 1;
@ -392,14 +392,18 @@ static int write_midx_included_packs(struct repack_write_midx_opts *opts)

ret = start_command(&cmd);
if (ret)
return ret;
goto done;

in = xfdopen(cmd.in, "w");
for_each_string_list_item(item, opts->include)
fprintf(in, "%s\n", item->string);
fclose(in);

return finish_command(&cmd);
ret = finish_command(&cmd);
done:
if (!ret && opts->write_bitmaps)
remove_redundant_bitmaps(opts->include, opts->packdir);
return ret;
}

static int finish_pack_objects_cmd(const struct git_hash_algo *algop,
@ -1003,9 +1007,6 @@ int cmd_repack(int argc,

ret = write_midx_included_packs(&opts);

if (!ret && write_bitmaps)
remove_redundant_bitmaps(&include, opts.packdir);

string_list_clear(&include, 0);

if (ret)