]> git.ipfire.org Git - thirdparty/git.git/commitdiff
midx.c: guard against commit_lock_file() failures
authorTaylor Blau <me@ttaylorr.com>
Fri, 8 Oct 2021 21:46:38 +0000 (17:46 -0400)
committerJunio C Hamano <gitster@pobox.com>
Fri, 15 Oct 2021 20:08:11 +0000 (13:08 -0700)
When writing a MIDX, we atomically move the new MIDX into place via
commit_lock_file(), but do not check to see if that call was successful.

Make sure that we do check in order to prevent us from incorrectly
reporting that we wrote a new MIDX if we actually encountered an error.

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 f2c976051de8c72a9e218ab189f3c597dcb9d384..8433086ac13c91a5c00fd4c97ef72341b2c06e3a 100644 (file)
--- a/midx.c
+++ b/midx.c
@@ -1423,7 +1423,8 @@ static int write_midx_internal(const char *object_dir,
        if (ctx.m)
                close_object_store(the_repository->objects);
 
-       commit_lock_file(&lk);
+       if (commit_lock_file(&lk) < 0)
+               die_errno(_("could not write multi-pack-index"));
 
        clear_midx_files_ext(object_dir, ".bitmap", midx_hash);
        clear_midx_files_ext(object_dir, ".rev", midx_hash);