midx.c: guard against commit_lock_file() failures

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>
This commit is contained in:
Taylor Blau 2021-10-08 17:46:38 -04:00 committed by Junio C Hamano
parent c0f1f9dec4
commit ae22e8415d

3
midx.c
View File

@ -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);