@@ -11,7 +11,6 @@ struct ref_lock {
11
11
char * orig_ref_name ;
12
12
struct lock_file * lk ;
13
13
unsigned char old_sha1 [20 ];
14
- int lock_fd ;
15
14
};
16
15
17
16
/*
@@ -2284,7 +2283,6 @@ static struct ref_lock *lock_ref_sha1_basic(const char *refname,
2284
2283
int attempts_remaining = 3 ;
2285
2284
2286
2285
lock = xcalloc (1 , sizeof (struct ref_lock ));
2287
- lock -> lock_fd = -1 ;
2288
2286
2289
2287
if (mustexist )
2290
2288
resolve_flags |= RESOLVE_REF_READING ;
@@ -2356,8 +2354,7 @@ static struct ref_lock *lock_ref_sha1_basic(const char *refname,
2356
2354
goto error_return ;
2357
2355
}
2358
2356
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 ) {
2361
2358
last_errno = errno ;
2362
2359
if (errno == ENOENT && -- attempts_remaining > 0 )
2363
2360
/*
@@ -2868,15 +2865,13 @@ static int close_ref(struct ref_lock *lock)
2868
2865
{
2869
2866
if (close_lock_file (lock -> lk ))
2870
2867
return -1 ;
2871
- lock -> lock_fd = -1 ;
2872
2868
return 0 ;
2873
2869
}
2874
2870
2875
2871
static int commit_ref (struct ref_lock * lock )
2876
2872
{
2877
2873
if (commit_lock_file (lock -> lk ))
2878
2874
return -1 ;
2879
- lock -> lock_fd = -1 ;
2880
2875
return 0 ;
2881
2876
}
2882
2877
@@ -3046,8 +3041,8 @@ static int write_ref_sha1(struct ref_lock *lock,
3046
3041
errno = EINVAL ;
3047
3042
return -1 ;
3048
3043
}
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 ||
3051
3046
close_ref (lock ) < 0 ) {
3052
3047
int save_errno = errno ;
3053
3048
error ("Couldn't write %s" , lock -> lk -> filename .buf );
@@ -4084,9 +4079,9 @@ int reflog_expire(const char *refname, const unsigned char *sha1,
4084
4079
status |= error ("couldn't write %s: %s" , log_file ,
4085
4080
strerror (errno ));
4086
4081
} else if (update &&
4087
- (write_in_full (lock -> lock_fd ,
4082
+ (write_in_full (lock -> lk -> fd ,
4088
4083
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 ||
4090
4085
close_ref (lock ) < 0 )) {
4091
4086
status |= error ("couldn't write %s" ,
4092
4087
lock -> lk -> filename .buf );
0 commit comments