@@ -1983,15 +1983,14 @@ static int remove_empty_directories(struct strbuf *path)
19831983 * Locks a ref returning the lock on success and NULL on failure.
19841984 * On failure errno is set to something meaningful.
19851985 */
1986- static struct ref_lock * lock_ref_sha1_basic (const char * refname ,
1986+ static struct ref_lock * lock_ref_sha1_basic (struct files_ref_store * refs ,
1987+ const char * refname ,
19871988 const unsigned char * old_sha1 ,
19881989 const struct string_list * extras ,
19891990 const struct string_list * skip ,
19901991 unsigned int flags , int * type ,
19911992 struct strbuf * err )
19921993{
1993- struct files_ref_store * refs =
1994- get_files_ref_store (NULL , "lock_ref_sha1_basic" );
19951994 struct strbuf ref_file = STRBUF_INIT ;
19961995 struct ref_lock * lock ;
19971996 int last_errno = 0 ;
@@ -2001,6 +2000,7 @@ static struct ref_lock *lock_ref_sha1_basic(const char *refname,
20012000 int attempts_remaining = 3 ;
20022001 int resolved ;
20032002
2003+ assert_main_repository (& refs -> base , "lock_ref_sha1_basic" );
20042004 assert (err );
20052005
20062006 lock = xcalloc (1 , sizeof (struct ref_lock ));
@@ -2644,8 +2644,8 @@ int rename_ref(const char *oldrefname, const char *newrefname, const char *logms
26442644
26452645 logmoved = log ;
26462646
2647- lock = lock_ref_sha1_basic (newrefname , NULL , NULL , NULL , REF_NODEREF ,
2648- NULL , & err );
2647+ lock = lock_ref_sha1_basic (refs , newrefname , NULL , NULL , NULL ,
2648+ REF_NODEREF , NULL , & err );
26492649 if (!lock ) {
26502650 error ("unable to rename '%s' to '%s': %s" , oldrefname , newrefname , err .buf );
26512651 strbuf_release (& err );
@@ -2663,8 +2663,8 @@ int rename_ref(const char *oldrefname, const char *newrefname, const char *logms
26632663 return 0 ;
26642664
26652665 rollback :
2666- lock = lock_ref_sha1_basic (oldrefname , NULL , NULL , NULL , REF_NODEREF ,
2667- NULL , & err );
2666+ lock = lock_ref_sha1_basic (refs , oldrefname , NULL , NULL , NULL ,
2667+ REF_NODEREF , NULL , & err );
26682668 if (!lock ) {
26692669 error ("unable to lock %s for rollback: %s" , oldrefname , err .buf );
26702670 strbuf_release (& err );
@@ -3020,13 +3020,14 @@ static int files_create_symref(struct ref_store *ref_store,
30203020 const char * refname , const char * target ,
30213021 const char * logmsg )
30223022{
3023+ struct files_ref_store * refs =
3024+ files_downcast (ref_store , 0 , "create_symref" );
30233025 struct strbuf err = STRBUF_INIT ;
30243026 struct ref_lock * lock ;
30253027 int ret ;
30263028
3027- files_downcast (ref_store , 0 , "create_symref" );
3028-
3029- lock = lock_ref_sha1_basic (refname , NULL , NULL , NULL , REF_NODEREF , NULL ,
3029+ lock = lock_ref_sha1_basic (refs , refname , NULL ,
3030+ NULL , NULL , REF_NODEREF , NULL ,
30303031 & err );
30313032 if (!lock ) {
30323033 error ("%s" , err .buf );
@@ -3929,6 +3930,8 @@ int reflog_expire(const char *refname, const unsigned char *sha1,
39293930 reflog_expiry_cleanup_fn cleanup_fn ,
39303931 void * policy_cb_data )
39313932{
3933+ struct files_ref_store * refs =
3934+ get_files_ref_store (NULL , "reflog_expire" );
39323935 static struct lock_file reflog_lock ;
39333936 struct expire_reflog_cb cb ;
39343937 struct ref_lock * lock ;
@@ -3947,7 +3950,8 @@ int reflog_expire(const char *refname, const unsigned char *sha1,
39473950 * reference itself, plus we might need to update the
39483951 * reference if --updateref was specified:
39493952 */
3950- lock = lock_ref_sha1_basic (refname , sha1 , NULL , NULL , REF_NODEREF ,
3953+ lock = lock_ref_sha1_basic (refs , refname , sha1 ,
3954+ NULL , NULL , REF_NODEREF ,
39513955 & type , & err );
39523956 if (!lock ) {
39533957 error ("cannot lock ref '%s': %s" , refname , err .buf );
0 commit comments