repack: refactor pack deletion for future use
The repack builtin deletes redundant pack-files and their associated .idx, .promisor, .bitmap, and .keep files. We will want to re-use this logic in the future for other types of repack, so pull the logic into 'unlink_pack_path()' in packfile.c. The 'ignore_keep' parameter is enabled for the use in repack, but will be important for a future caller. Signed-off-by: Derrick Stolee <dstolee@microsoft.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:

committed by
Junio C Hamano

parent
b697d92f56
commit
8434e85d5f
@ -129,19 +129,9 @@ static void get_non_kept_pack_filenames(struct string_list *fname_list,
|
||||
|
||||
static void remove_redundant_pack(const char *dir_name, const char *base_name)
|
||||
{
|
||||
const char *exts[] = {".pack", ".idx", ".keep", ".bitmap", ".promisor"};
|
||||
int i;
|
||||
struct strbuf buf = STRBUF_INIT;
|
||||
size_t plen;
|
||||
|
||||
strbuf_addf(&buf, "%s/%s", dir_name, base_name);
|
||||
plen = buf.len;
|
||||
|
||||
for (i = 0; i < ARRAY_SIZE(exts); i++) {
|
||||
strbuf_setlen(&buf, plen);
|
||||
strbuf_addstr(&buf, exts[i]);
|
||||
unlink(buf.buf);
|
||||
}
|
||||
strbuf_addf(&buf, "%s/%s.pack", dir_name, base_name);
|
||||
unlink_pack_path(buf.buf, 1);
|
||||
strbuf_release(&buf);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user