]> git.ipfire.org Git - thirdparty/git.git/commitdiff
midx: don't peek into `struct lock_file`
authorMartin Ågren <martin.agren@gmail.com>
Tue, 5 Jan 2021 19:23:48 +0000 (20:23 +0100)
committerJunio C Hamano <gitster@pobox.com>
Wed, 6 Jan 2021 21:53:32 +0000 (13:53 -0800)
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 <martin.agren@gmail.com>
Reviewed-by: Derrick Stolee <dstolee@microsoft.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
midx.c

diff --git a/midx.c b/midx.c
index 79c282b070d26d5ffac866feaaee244fea986d43..9d41b9c2716b9c54cc8ef1c5d97b96d8db6fcce2 100644 (file)
--- a/midx.c
+++ b/midx.c
@@ -918,7 +918,7 @@ static int write_midx_internal(const char *object_dir, struct multi_pack_index *
                                        (pack_name_concat_len % MIDX_CHUNK_ALIGNMENT);
 
        hold_lock_file_for_update(&lk, midx_name, LOCK_DIE_ON_ERROR);
-       f = hashfd(lk.tempfile->fd, lk.tempfile->filename.buf);
+       f = hashfd(get_lock_file_fd(&lk), get_lock_file_path(&lk));
        FREE_AND_NULL(midx_name);
 
        if (packs.m)