@@ -770,21 +770,21 @@ static struct ref_iterator *files_ref_iterator_begin(
770770}
771771
772772/*
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.
777777 */
778778static 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 ,
780780 struct strbuf * err )
781781{
782782 assert (err );
783783
784784 if (refs_read_ref_full (ref_store , lock -> ref_name ,
785785 mustexist ? RESOLVE_REF_READING : 0 ,
786786 & lock -> old_oid , NULL )) {
787- if (old_sha1 ) {
787+ if (old_oid ) {
788788 int save_errno = errno ;
789789 strbuf_addf (err , "can't verify ref '%s'" , lock -> ref_name );
790790 errno = save_errno ;
@@ -794,11 +794,11 @@ static int verify_lock(struct ref_store *ref_store, struct ref_lock *lock,
794794 return 0 ;
795795 }
796796 }
797- if (old_sha1 && hashcmp ( lock -> old_oid . hash , old_sha1 )) {
797+ if (old_oid && oidcmp ( & lock -> old_oid , old_oid )) {
798798 strbuf_addf (err , "ref '%s' is at %s but expected %s" ,
799799 lock -> ref_name ,
800800 oid_to_hex (& lock -> old_oid ),
801- sha1_to_hex ( old_sha1 ));
801+ oid_to_hex ( old_oid ));
802802 errno = EBUSY ;
803803 return -1 ;
804804 }
@@ -828,22 +828,22 @@ static int create_reflock(const char *path, void *cb)
828828 * Locks a ref returning the lock on success and NULL on failure.
829829 * On failure errno is set to something meaningful.
830830 */
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 )
838838{
839839 struct strbuf ref_file = STRBUF_INIT ;
840840 struct ref_lock * lock ;
841841 int last_errno = 0 ;
842- int mustexist = (old_sha1 && !is_null_sha1 ( old_sha1 ));
842+ int mustexist = (old_oid && !is_null_oid ( old_oid ));
843843 int resolve_flags = RESOLVE_REF_NO_RECURSE ;
844844 int resolved ;
845845
846- files_assert_main_repository (refs , "lock_ref_sha1_basic " );
846+ files_assert_main_repository (refs , "lock_ref_oid_basic " );
847847 assert (err );
848848
849849 lock = xcalloc (1 , sizeof (struct ref_lock ));
@@ -909,7 +909,7 @@ static struct ref_lock *lock_ref_sha1_basic(struct files_ref_store *refs,
909909 goto error_return ;
910910 }
911911
912- if (verify_lock (& refs -> base , lock , old_sha1 , mustexist , err )) {
912+ if (verify_lock (& refs -> base , lock , old_oid , mustexist , err )) {
913913 last_errno = errno ;
914914 goto error_return ;
915915 }
@@ -1324,8 +1324,8 @@ static int files_copy_or_rename_ref(struct ref_store *ref_store,
13241324
13251325 logmoved = log ;
13261326
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 );
13291329 if (!lock ) {
13301330 if (copy )
13311331 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,
13471347 goto out ;
13481348
13491349 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 );
13521352 if (!lock ) {
13531353 error ("unable to lock %s for rollback: %s" , oldrefname , err .buf );
13541354 strbuf_release (& err );
@@ -1763,9 +1763,9 @@ static int files_create_symref(struct ref_store *ref_store,
17631763 struct ref_lock * lock ;
17641764 int ret ;
17651765
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 );
17691769 if (!lock ) {
17701770 error ("%s" , err .buf );
17711771 strbuf_release (& err );
@@ -2937,9 +2937,9 @@ static int files_reflog_expire(struct ref_store *ref_store,
29372937 * reference itself, plus we might need to update the
29382938 * reference if --updateref was specified:
29392939 */
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 );
29432943 if (!lock ) {
29442944 error ("cannot lock ref '%s': %s" , refname , err .buf );
29452945 strbuf_release (& err );
0 commit comments