refs/files-backend: 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. Note how we obtain the path to the lock file if `fdopen_lock_file()` failed and that this is not a problem: as documented in lockfile.h, failure to "fdopen" does not roll back the lock file and we're free to, e.g., query it for its path. 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>
Martin Ågren committed
Jan 5, 2021 at 20:23 UTC
7f0dc7998be01371c99517dc616421239405476c
1 file changed
+2
-2
refs/files-backend.c
+2
-2
@@ -1824,12 +1824,12 @@ static int create_symref_locked(struct files_ref_store *refs,
1824
1825
if (!fdopen_lock_file(&lock->lk, "w"))
1826
return error("unable to fdopen %s: %s",
1827
- lock->lk.tempfile->filename.buf, strerror(errno));
1827
+ get_lock_file_path(&lock->lk), strerror(errno));
1828
1829
update_symref_reflog(refs, lock, refname, target, logmsg);
1830
1831
/* no error check; commit_ref will check ferror */
1832
- fprintf(lock->lk.tempfile->fp, "ref: %s\n", target);
1832
+ fprintf(get_lock_file_fp(&lock->lk), "ref: %s\n", target);
1833
if (commit_ref(lock) < 0)
1834
return error("unable to write symref for %s: %s", refname,
1835
strerror(errno));