]> git.ipfire.org Git - thirdparty/git.git/commitdiff
midx: clear auxiliary .rev after replacing the MIDX
authorTaylor Blau <me@ttaylorr.com>
Tue, 31 Aug 2021 20:51:59 +0000 (16:51 -0400)
committerJunio C Hamano <gitster@pobox.com>
Wed, 1 Sep 2021 17:58:43 +0000 (10:58 -0700)
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>
midx.c

diff --git a/midx.c b/midx.c
index 902e1a7a7d9df1ff77ad9d9eb7fc8e54a7ddb1c2..0bcb403bae23a4b7ada87735f4ecc1f687cc4be9 100644 (file)
--- a/midx.c
+++ b/midx.c
@@ -1086,10 +1086,11 @@ static int write_midx_internal(const char *object_dir, struct multi_pack_index *
 
        if (flags & MIDX_WRITE_REV_INDEX)
                write_midx_reverse_index(midx_name, midx_hash, &ctx);
-       clear_midx_files_ext(object_dir, ".rev", midx_hash);
 
        commit_lock_file(&lk);
 
+       clear_midx_files_ext(object_dir, ".rev", midx_hash);
+
 cleanup:
        for (i = 0; i < ctx.nr; i++) {
                if (ctx.info[i].p) {