]> git.ipfire.org Git - thirdparty/git.git/commitdiff
builtin/repack.c: inline `remove_redundant_bitmaps()`
authorTaylor Blau <me@ttaylorr.com>
Wed, 15 Oct 2025 22:29:05 +0000 (18:29 -0400)
committerJunio C Hamano <gitster@pobox.com>
Thu, 16 Oct 2025 17:08:56 +0000 (10:08 -0700)
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>
builtin/repack.c

index 865e0af039d6851ca2768f7fd390e5788bc84434..271c86926898a0b287c217fc58098a48ef1c431d 100644 (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)