Skip to content

Commit ae22e84

Browse files
ttaylorrgitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent c0f1f9d commit ae22e84

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

midx.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1423,7 +1423,8 @@ static int write_midx_internal(const char *object_dir,
14231423
if (ctx.m)
14241424
close_object_store(the_repository->objects);
14251425

1426-
commit_lock_file(&lk);
1426+
if (commit_lock_file(&lk) < 0)
1427+
die_errno(_("could not write multi-pack-index"));
14271428

14281429
clear_midx_files_ext(object_dir, ".bitmap", midx_hash);
14291430
clear_midx_files_ext(object_dir, ".rev", midx_hash);

0 commit comments

Comments
 (0)