Skip to content

Commit acd7160

Browse files
Martin Ågrengitster
authored andcommitted
midx: don't peek into struct lock_file
Similar to the previous commits, avoid peeking into the `struct lock_file`. Use the lock file API instead. The two functions we're calling here double-check that the tempfile is indeed "active", which is arguably overkill considering how we took the lock on the line immediately above. More importantly, this future-proofs us against, e.g., other code appearing between these two lines or the lock file and/or tempfile internals changing. Signed-off-by: Martin Ågren <[email protected]> Reviewed-by: Derrick Stolee <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent a52cdce commit acd7160

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

midx.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -918,7 +918,7 @@ static int write_midx_internal(const char *object_dir, struct multi_pack_index *
918918
(pack_name_concat_len % MIDX_CHUNK_ALIGNMENT);
919919

920920
hold_lock_file_for_update(&lk, midx_name, LOCK_DIE_ON_ERROR);
921-
f = hashfd(lk.tempfile->fd, lk.tempfile->filename.buf);
921+
f = hashfd(get_lock_file_fd(&lk), get_lock_file_path(&lk));
922922
FREE_AND_NULL(midx_name);
923923

924924
if (packs.m)

0 commit comments

Comments
 (0)