lockfile: add accessors get_lock_file_fd() and get_lock_file_fp()
We are about to move those members, so change client code to read them through accessor functions. Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:

committed by
Junio C Hamano

parent
e54c347c1c
commit
c99a4c2db3
12
refs.c
12
refs.c
@ -3162,6 +3162,7 @@ static int write_ref_to_lockfile(struct ref_lock *lock,
|
||||
{
|
||||
static char term = '\n';
|
||||
struct object *o;
|
||||
int fd;
|
||||
|
||||
o = parse_object(sha1);
|
||||
if (!o) {
|
||||
@ -3178,8 +3179,9 @@ static int write_ref_to_lockfile(struct ref_lock *lock,
|
||||
errno = EINVAL;
|
||||
return -1;
|
||||
}
|
||||
if (write_in_full(lock->lk->fd, sha1_to_hex(sha1), 40) != 40 ||
|
||||
write_in_full(lock->lk->fd, &term, 1) != 1 ||
|
||||
fd = get_lock_file_fd(lock->lk);
|
||||
if (write_in_full(fd, sha1_to_hex(sha1), 40) != 40 ||
|
||||
write_in_full(fd, &term, 1) != 1 ||
|
||||
close_ref(lock) < 0) {
|
||||
int save_errno = errno;
|
||||
error("Couldn't write %s", lock->lk->filename.buf);
|
||||
@ -4264,10 +4266,10 @@ int reflog_expire(const char *refname, const unsigned char *sha1,
|
||||
status |= error("couldn't write %s: %s", log_file,
|
||||
strerror(errno));
|
||||
} else if (update &&
|
||||
(write_in_full(lock->lk->fd,
|
||||
(write_in_full(get_lock_file_fd(lock->lk),
|
||||
sha1_to_hex(cb.last_kept_sha1), 40) != 40 ||
|
||||
write_str_in_full(lock->lk->fd, "\n") != 1 ||
|
||||
close_ref(lock) < 0)) {
|
||||
write_str_in_full(get_lock_file_fd(lock->lk), "\n") != 1 ||
|
||||
close_ref(lock) < 0)) {
|
||||
status |= error("couldn't write %s",
|
||||
lock->lk->filename.buf);
|
||||
rollback_lock_file(&reflog_lock);
|
||||
|
Reference in New Issue
Block a user