@@ -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/*
@@ -2302,7 +2301,6 @@ static struct ref_lock *lock_ref_sha1_basic(const char *refname,
23022301 int attempts_remaining = 3 ;
23032302
23042303 lock = xcalloc (1 , sizeof (struct ref_lock ));
2305- lock -> lock_fd = -1 ;
23062304
23072305 if (mustexist )
23082306 resolve_flags |= RESOLVE_REF_READING ;
@@ -2374,8 +2372,7 @@ static struct ref_lock *lock_ref_sha1_basic(const char *refname,
23742372 goto error_return ;
23752373 }
23762374
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 ) {
23792376 last_errno = errno ;
23802377 if (errno == ENOENT && -- attempts_remaining > 0 )
23812378 /*
@@ -2886,15 +2883,13 @@ static int close_ref(struct ref_lock *lock)
28862883{
28872884 if (close_lock_file (lock -> lk ))
28882885 return -1 ;
2889- lock -> lock_fd = -1 ;
28902886 return 0 ;
28912887}
28922888
28932889static int commit_ref (struct ref_lock * lock )
28942890{
28952891 if (commit_lock_file (lock -> lk ))
28962892 return -1 ;
2897- lock -> lock_fd = -1 ;
28982893 return 0 ;
28992894}
29002895
@@ -3081,8 +3076,8 @@ static int write_ref_sha1(struct ref_lock *lock,
30813076 errno = EINVAL ;
30823077 return -1 ;
30833078 }
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 ||
30863081 close_ref (lock ) < 0 ) {
30873082 int save_errno = errno ;
30883083 error ("Couldn't write %s" , lock -> lk -> filename .buf );
@@ -4119,9 +4114,9 @@ int reflog_expire(const char *refname, const unsigned char *sha1,
41194114 status |= error ("couldn't write %s: %s" , log_file ,
41204115 strerror (errno ));
41214116 } else if (update &&
4122- (write_in_full (lock -> lock_fd ,
4117+ (write_in_full (lock -> lk -> fd ,
41234118 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 ||
41254120 close_ref (lock ) < 0 )) {
41264121 status |= error ("couldn't write %s" ,
41274122 lock -> lk -> filename .buf );
0 commit comments