@@ -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
/*
@@ -2302,7 +2301,6 @@ static struct ref_lock *lock_ref_sha1_basic(const char *refname,
2302
2301
int attempts_remaining = 3 ;
2303
2302
2304
2303
lock = xcalloc (1 , sizeof (struct ref_lock ));
2305
- lock -> lock_fd = -1 ;
2306
2304
2307
2305
if (mustexist )
2308
2306
resolve_flags |= RESOLVE_REF_READING ;
@@ -2374,8 +2372,7 @@ static struct ref_lock *lock_ref_sha1_basic(const char *refname,
2374
2372
goto error_return ;
2375
2373
}
2376
2374
2377
- lock -> lock_fd = hold_lock_file_for_update (lock -> lk , ref_file , lflags );
2378
- if (lock -> lock_fd < 0 ) {
2375
+ if (hold_lock_file_for_update (lock -> lk , ref_file , lflags ) < 0 ) {
2379
2376
last_errno = errno ;
2380
2377
if (errno == ENOENT && -- attempts_remaining > 0 )
2381
2378
/*
@@ -2886,15 +2883,13 @@ static int close_ref(struct ref_lock *lock)
2886
2883
{
2887
2884
if (close_lock_file (lock -> lk ))
2888
2885
return -1 ;
2889
- lock -> lock_fd = -1 ;
2890
2886
return 0 ;
2891
2887
}
2892
2888
2893
2889
static int commit_ref (struct ref_lock * lock )
2894
2890
{
2895
2891
if (commit_lock_file (lock -> lk ))
2896
2892
return -1 ;
2897
- lock -> lock_fd = -1 ;
2898
2893
return 0 ;
2899
2894
}
2900
2895
@@ -3081,8 +3076,8 @@ static int write_ref_sha1(struct ref_lock *lock,
3081
3076
errno = EINVAL ;
3082
3077
return -1 ;
3083
3078
}
3084
- if (write_in_full (lock -> lock_fd , sha1_to_hex (sha1 ), 40 ) != 40 ||
3085
- write_in_full (lock -> lock_fd , & term , 1 ) != 1 ||
3079
+ if (write_in_full (lock -> lk -> fd , sha1_to_hex (sha1 ), 40 ) != 40 ||
3080
+ write_in_full (lock -> lk -> fd , & term , 1 ) != 1 ||
3086
3081
close_ref (lock ) < 0 ) {
3087
3082
int save_errno = errno ;
3088
3083
error ("Couldn't write %s" , lock -> lk -> filename .buf );
@@ -4119,9 +4114,9 @@ int reflog_expire(const char *refname, const unsigned char *sha1,
4119
4114
status |= error ("couldn't write %s: %s" , log_file ,
4120
4115
strerror (errno ));
4121
4116
} else if (update &&
4122
- (write_in_full (lock -> lock_fd ,
4117
+ (write_in_full (lock -> lk -> fd ,
4123
4118
sha1_to_hex (cb .last_kept_sha1 ), 40 ) != 40 ||
4124
- write_str_in_full (lock -> lock_fd , "\n" ) != 1 ||
4119
+ write_str_in_full (lock -> lk -> fd , "\n" ) != 1 ||
4125
4120
close_ref (lock ) < 0 )) {
4126
4121
status |= error ("couldn't write %s" ,
4127
4122
lock -> lk -> filename .buf );
0 commit comments