@@ -770,21 +770,21 @@ static struct ref_iterator *files_ref_iterator_begin(
770
770
}
771
771
772
772
/*
773
- * Verify that the reference locked by lock has the value old_sha1.
774
- * Fail if the reference doesn't exist and mustexist is set. Return 0
775
- * on success. On error, write an error message to err, set errno, and
776
- * return a negative value.
773
+ * Verify that the reference locked by lock has the value old_oid
774
+ * (unless it is NULL). Fail if the reference doesn't exist and
775
+ * mustexist is set. Return 0 on success. On error, write an error
776
+ * message to err, set errno, and return a negative value.
777
777
*/
778
778
static int verify_lock (struct ref_store * ref_store , struct ref_lock * lock ,
779
- const unsigned char * old_sha1 , int mustexist ,
779
+ const struct object_id * old_oid , int mustexist ,
780
780
struct strbuf * err )
781
781
{
782
782
assert (err );
783
783
784
784
if (refs_read_ref_full (ref_store , lock -> ref_name ,
785
785
mustexist ? RESOLVE_REF_READING : 0 ,
786
786
& lock -> old_oid , NULL )) {
787
- if (old_sha1 ) {
787
+ if (old_oid ) {
788
788
int save_errno = errno ;
789
789
strbuf_addf (err , "can't verify ref '%s'" , lock -> ref_name );
790
790
errno = save_errno ;
@@ -794,11 +794,11 @@ static int verify_lock(struct ref_store *ref_store, struct ref_lock *lock,
794
794
return 0 ;
795
795
}
796
796
}
797
- if (old_sha1 && hashcmp ( lock -> old_oid . hash , old_sha1 )) {
797
+ if (old_oid && oidcmp ( & lock -> old_oid , old_oid )) {
798
798
strbuf_addf (err , "ref '%s' is at %s but expected %s" ,
799
799
lock -> ref_name ,
800
800
oid_to_hex (& lock -> old_oid ),
801
- sha1_to_hex ( old_sha1 ));
801
+ oid_to_hex ( old_oid ));
802
802
errno = EBUSY ;
803
803
return -1 ;
804
804
}
@@ -828,22 +828,22 @@ static int create_reflock(const char *path, void *cb)
828
828
* Locks a ref returning the lock on success and NULL on failure.
829
829
* On failure errno is set to something meaningful.
830
830
*/
831
- static struct ref_lock * lock_ref_sha1_basic (struct files_ref_store * refs ,
832
- const char * refname ,
833
- const unsigned char * old_sha1 ,
834
- const struct string_list * extras ,
835
- const struct string_list * skip ,
836
- unsigned int flags , int * type ,
837
- struct strbuf * err )
831
+ static struct ref_lock * lock_ref_oid_basic (struct files_ref_store * refs ,
832
+ const char * refname ,
833
+ const struct object_id * old_oid ,
834
+ const struct string_list * extras ,
835
+ const struct string_list * skip ,
836
+ unsigned int flags , int * type ,
837
+ struct strbuf * err )
838
838
{
839
839
struct strbuf ref_file = STRBUF_INIT ;
840
840
struct ref_lock * lock ;
841
841
int last_errno = 0 ;
842
- int mustexist = (old_sha1 && !is_null_sha1 ( old_sha1 ));
842
+ int mustexist = (old_oid && !is_null_oid ( old_oid ));
843
843
int resolve_flags = RESOLVE_REF_NO_RECURSE ;
844
844
int resolved ;
845
845
846
- files_assert_main_repository (refs , "lock_ref_sha1_basic " );
846
+ files_assert_main_repository (refs , "lock_ref_oid_basic " );
847
847
assert (err );
848
848
849
849
lock = xcalloc (1 , sizeof (struct ref_lock ));
@@ -909,7 +909,7 @@ static struct ref_lock *lock_ref_sha1_basic(struct files_ref_store *refs,
909
909
goto error_return ;
910
910
}
911
911
912
- if (verify_lock (& refs -> base , lock , old_sha1 , mustexist , err )) {
912
+ if (verify_lock (& refs -> base , lock , old_oid , mustexist , err )) {
913
913
last_errno = errno ;
914
914
goto error_return ;
915
915
}
@@ -1324,8 +1324,8 @@ static int files_copy_or_rename_ref(struct ref_store *ref_store,
1324
1324
1325
1325
logmoved = log ;
1326
1326
1327
- lock = lock_ref_sha1_basic (refs , newrefname , NULL , NULL , NULL ,
1328
- REF_NODEREF , NULL , & err );
1327
+ lock = lock_ref_oid_basic (refs , newrefname , NULL , NULL , NULL ,
1328
+ REF_NODEREF , NULL , & err );
1329
1329
if (!lock ) {
1330
1330
if (copy )
1331
1331
error ("unable to copy '%s' to '%s': %s" , oldrefname , newrefname , err .buf );
@@ -1347,8 +1347,8 @@ static int files_copy_or_rename_ref(struct ref_store *ref_store,
1347
1347
goto out ;
1348
1348
1349
1349
rollback :
1350
- lock = lock_ref_sha1_basic (refs , oldrefname , NULL , NULL , NULL ,
1351
- REF_NODEREF , NULL , & err );
1350
+ lock = lock_ref_oid_basic (refs , oldrefname , NULL , NULL , NULL ,
1351
+ REF_NODEREF , NULL , & err );
1352
1352
if (!lock ) {
1353
1353
error ("unable to lock %s for rollback: %s" , oldrefname , err .buf );
1354
1354
strbuf_release (& err );
@@ -1763,9 +1763,9 @@ static int files_create_symref(struct ref_store *ref_store,
1763
1763
struct ref_lock * lock ;
1764
1764
int ret ;
1765
1765
1766
- lock = lock_ref_sha1_basic (refs , refname , NULL ,
1767
- NULL , NULL , REF_NODEREF , NULL ,
1768
- & err );
1766
+ lock = lock_ref_oid_basic (refs , refname , NULL ,
1767
+ NULL , NULL , REF_NODEREF , NULL ,
1768
+ & err );
1769
1769
if (!lock ) {
1770
1770
error ("%s" , err .buf );
1771
1771
strbuf_release (& err );
@@ -2937,9 +2937,9 @@ static int files_reflog_expire(struct ref_store *ref_store,
2937
2937
* reference itself, plus we might need to update the
2938
2938
* reference if --updateref was specified:
2939
2939
*/
2940
- lock = lock_ref_sha1_basic (refs , refname , oid -> hash ,
2941
- NULL , NULL , REF_NODEREF ,
2942
- & type , & err );
2940
+ lock = lock_ref_oid_basic (refs , refname , oid ,
2941
+ NULL , NULL , REF_NODEREF ,
2942
+ & type , & err );
2943
2943
if (!lock ) {
2944
2944
error ("cannot lock ref '%s': %s" , refname , err .buf );
2945
2945
strbuf_release (& err );
0 commit comments