aboutsummaryrefslogtreecommitdiff
path: root/refs.c
diff options
context:
space:
mode:
authorMichael Haggerty <mhagger@alum.mit.edu>2015-08-10 11:47:38 +0200
committerJunio C Hamano <gitster@pobox.com>2015-08-10 12:57:14 -0700
commitc99a4c2db3053e4fb6a43870f5c747f858b0f58f (patch)
treeb481895c6cee3a3ddf964e4a7f06e1453ce9824d /refs.c
parente54c347c1c444c0f37b64b8735c50a66ee0527e9 (diff)
downloadgit-c99a4c2db3053e4fb6a43870f5c747f858b0f58f.tar.gz
git-c99a4c2db3053e4fb6a43870f5c747f858b0f58f.tar.xz
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>
Diffstat (limited to 'refs.c')
-rw-r--r--refs.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/refs.c b/refs.c
index a742d7925..0f49a6210 100644
--- a/refs.c
+++ b/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);