Skip to content

Commit 7f0dc79

Browse files
Martin Ågrengitster
authored andcommitted
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 <[email protected]> Reviewed-by: Derrick Stolee <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent acd7160 commit 7f0dc79

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

refs/files-backend.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1824,12 +1824,12 @@ static int create_symref_locked(struct files_ref_store *refs,
18241824

18251825
if (!fdopen_lock_file(&lock->lk, "w"))
18261826
return error("unable to fdopen %s: %s",
1827-
lock->lk.tempfile->filename.buf, strerror(errno));
1827+
get_lock_file_path(&lock->lk), strerror(errno));
18281828

18291829
update_symref_reflog(refs, lock, refname, target, logmsg);
18301830

18311831
/* 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);
18331833
if (commit_ref(lock) < 0)
18341834
return error("unable to write symref for %s: %s", refname,
18351835
strerror(errno));

0 commit comments

Comments
 (0)