Skip to content

Commit 337baea

Browse files
ttaylorrgitster
authored andcommitted
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>
1 parent 42088e3 commit 337baea

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

builtin/repack.c

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -331,10 +331,10 @@ static int write_midx_included_packs(struct repack_write_midx_opts *opts)
331331
struct string_list_item *item;
332332
struct packed_git *preferred = pack_geometry_preferred_pack(opts->geometry);
333333
FILE *in;
334-
int ret;
334+
int ret = 0;
335335

336336
if (!opts->include->nr)
337-
return 0;
337+
goto done;
338338

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

393393
ret = start_command(&cmd);
394394
if (ret)
395-
return ret;
395+
goto done;
396396

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

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;
403407
}
404408

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

10041008
ret = write_midx_included_packs(&opts);
10051009

1006-
if (!ret && write_bitmaps)
1007-
remove_redundant_bitmaps(&include, opts.packdir);
1008-
10091010
string_list_clear(&include, 0);
10101011

10111012
if (ret)

0 commit comments

Comments
 (0)