midx: clear auxiliary .rev after replacing the MIDX
When writing a new multi-pack index, write_midx_internal() attempts to clean up any auxiliary files (currently just the MIDX's `.rev` file, but soon to include a `.bitmap`, too) corresponding to the MIDX it's replacing. This step should happen after the new MIDX is written into place, since doing so beforehand means that the old MIDX could be read without its corresponding .rev file. Signed-off-by: Taylor Blau <me@ttaylorr.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Taylor Blau committed
Aug 31, 2021 at 16:51 UTC
f5909d34ca4956744bc6e058d30546a5ab28ee8b
1 file changed
+2
-1
midx.c
+2
-1
@@ -1086,10 +1086,11 @@ static int write_midx_internal(const char *object_dir, struct multi_pack_index *
1086
1087
if (flags & MIDX_WRITE_REV_INDEX)
1088
write_midx_reverse_index(midx_name, midx_hash, &ctx);
1089
- clear_midx_files_ext(object_dir, ".rev", midx_hash);
1089
1090
commit_lock_file(&lk);
1091
1092
+ clear_midx_files_ext(object_dir, ".rev", midx_hash);
1093
+
1094
cleanup:
1095
for (i = 0; i < ctx.nr; i++) {
1096
if (ctx.info[i].p) {