Skip to content

Commit 1238ac8

Browse files
stefanbellergitster
authored andcommitted
refs.c: remove lock_fd from struct ref_lock
The 'lock_fd' is the same as 'lk->fd'. No need to store it twice so remove it. No functional changes intended. Signed-off-by: Stefan Beller <[email protected]> Reviewed-by: Michael Haggerty <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 8440f74 commit 1238ac8

File tree

1 file changed

+5
-10
lines changed

1 file changed

+5
-10
lines changed

refs.c

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ struct ref_lock {
1111
char *orig_ref_name;
1212
struct lock_file *lk;
1313
unsigned char old_sha1[20];
14-
int lock_fd;
1514
};
1615

1716
/*
@@ -2284,7 +2283,6 @@ static struct ref_lock *lock_ref_sha1_basic(const char *refname,
22842283
int attempts_remaining = 3;
22852284

22862285
lock = xcalloc(1, sizeof(struct ref_lock));
2287-
lock->lock_fd = -1;
22882286

22892287
if (mustexist)
22902288
resolve_flags |= RESOLVE_REF_READING;
@@ -2356,8 +2354,7 @@ static struct ref_lock *lock_ref_sha1_basic(const char *refname,
23562354
goto error_return;
23572355
}
23582356

2359-
lock->lock_fd = hold_lock_file_for_update(lock->lk, ref_file, lflags);
2360-
if (lock->lock_fd < 0) {
2357+
if (hold_lock_file_for_update(lock->lk, ref_file, lflags) < 0) {
23612358
last_errno = errno;
23622359
if (errno == ENOENT && --attempts_remaining > 0)
23632360
/*
@@ -2868,15 +2865,13 @@ static int close_ref(struct ref_lock *lock)
28682865
{
28692866
if (close_lock_file(lock->lk))
28702867
return -1;
2871-
lock->lock_fd = -1;
28722868
return 0;
28732869
}
28742870

28752871
static int commit_ref(struct ref_lock *lock)
28762872
{
28772873
if (commit_lock_file(lock->lk))
28782874
return -1;
2879-
lock->lock_fd = -1;
28802875
return 0;
28812876
}
28822877

@@ -3046,8 +3041,8 @@ static int write_ref_sha1(struct ref_lock *lock,
30463041
errno = EINVAL;
30473042
return -1;
30483043
}
3049-
if (write_in_full(lock->lock_fd, sha1_to_hex(sha1), 40) != 40 ||
3050-
write_in_full(lock->lock_fd, &term, 1) != 1 ||
3044+
if (write_in_full(lock->lk->fd, sha1_to_hex(sha1), 40) != 40 ||
3045+
write_in_full(lock->lk->fd, &term, 1) != 1 ||
30513046
close_ref(lock) < 0) {
30523047
int save_errno = errno;
30533048
error("Couldn't write %s", lock->lk->filename.buf);
@@ -4084,9 +4079,9 @@ int reflog_expire(const char *refname, const unsigned char *sha1,
40844079
status |= error("couldn't write %s: %s", log_file,
40854080
strerror(errno));
40864081
} else if (update &&
4087-
(write_in_full(lock->lock_fd,
4082+
(write_in_full(lock->lk->fd,
40884083
sha1_to_hex(cb.last_kept_sha1), 40) != 40 ||
4089-
write_str_in_full(lock->lock_fd, "\n") != 1 ||
4084+
write_str_in_full(lock->lk->fd, "\n") != 1 ||
40904085
close_ref(lock) < 0)) {
40914086
status |= error("couldn't write %s",
40924087
lock->lk->filename.buf);

0 commit comments

Comments
 (0)