Merge branch 'tb/remove-unused-pack-bitmap'
When creating a multi-pack bitmap, remove per-pack bitmap files unconditionally as they will never be consulted. * tb/remove-unused-pack-bitmap: builtin/repack.c: remove redundant pack-based bitmaps
This commit is contained in:
@ -661,6 +661,35 @@ static int write_midx_included_packs(struct string_list *include,
|
||||
return finish_command(&cmd);
|
||||
}
|
||||
|
||||
static void remove_redundant_bitmaps(struct string_list *include,
|
||||
const char *packdir)
|
||||
{
|
||||
struct strbuf path = STRBUF_INIT;
|
||||
struct string_list_item *item;
|
||||
size_t packdir_len;
|
||||
|
||||
strbuf_addstr(&path, packdir);
|
||||
strbuf_addch(&path, '/');
|
||||
packdir_len = path.len;
|
||||
|
||||
/*
|
||||
* Remove any pack bitmaps corresponding to packs which are now
|
||||
* included in the MIDX.
|
||||
*/
|
||||
for_each_string_list_item(item, include) {
|
||||
strbuf_addstr(&path, item->string);
|
||||
strbuf_strip_suffix(&path, ".idx");
|
||||
strbuf_addstr(&path, ".bitmap");
|
||||
|
||||
if (unlink(path.buf) && errno != ENOENT)
|
||||
warning_errno(_("could not remove stale bitmap: %s"),
|
||||
path.buf);
|
||||
|
||||
strbuf_setlen(&path, packdir_len);
|
||||
}
|
||||
strbuf_release(&path);
|
||||
}
|
||||
|
||||
static int write_cruft_pack(const struct pack_objects_args *args,
|
||||
const char *pack_prefix,
|
||||
struct string_list *names,
|
||||
@ -1059,6 +1088,9 @@ int cmd_repack(int argc, const char **argv, const char *prefix)
|
||||
refs_snapshot ? get_tempfile_path(refs_snapshot) : NULL,
|
||||
show_progress, write_bitmaps > 0);
|
||||
|
||||
if (!ret && write_bitmaps)
|
||||
remove_redundant_bitmaps(&include, packdir);
|
||||
|
||||
string_list_clear(&include, 0);
|
||||
|
||||
if (ret)
|
||||
|
Reference in New Issue
Block a user