midx: clear midx on repack

If a 'git repack' command replaces existing packfiles, then we must
clear the existing multi-pack-index before moving the packfiles it
references.

Signed-off-by: Derrick Stolee <dstolee@microsoft.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Derrick Stolee
2018-07-12 15:39:40 -04:00
committed by Junio C Hamano
parent 17c35c8969
commit 525e18c04b
4 changed files with 31 additions and 0 deletions

12
midx.c
View File

@ -904,3 +904,15 @@ cleanup:
free(midx_name);
return 0;
}
void clear_midx_file(const char *object_dir)
{
char *midx = get_midx_filename(object_dir);
if (remove_path(midx)) {
UNLEAK(midx);
die(_("failed to clear multi-pack-index at %s"), midx);
}
free(midx);
}