@@ -671,8 +671,7 @@ int refs_delete_ref(struct ref_store *refs, const char *msg,
671671
672672 transaction = ref_store_transaction_begin (refs , & err );
673673 if (!transaction ||
674- ref_transaction_delete (transaction , refname ,
675- old_oid ? old_oid -> hash : NULL ,
674+ ref_transaction_delete (transaction , refname , old_oid ,
676675 flags , msg , & err ) ||
677676 ref_transaction_commit (transaction , & err )) {
678677 error ("%s" , err .buf );
@@ -898,8 +897,8 @@ void ref_transaction_free(struct ref_transaction *transaction)
898897struct ref_update * ref_transaction_add_update (
899898 struct ref_transaction * transaction ,
900899 const char * refname , unsigned int flags ,
901- const unsigned char * new_sha1 ,
902- const unsigned char * old_sha1 ,
900+ const struct object_id * new_oid ,
901+ const struct object_id * old_oid ,
903902 const char * msg )
904903{
905904 struct ref_update * update ;
@@ -917,23 +916,23 @@ struct ref_update *ref_transaction_add_update(
917916 update -> flags = flags ;
918917
919918 if (flags & REF_HAVE_NEW )
920- hashcpy ( update -> new_oid . hash , new_sha1 );
919+ oidcpy ( & update -> new_oid , new_oid );
921920 if (flags & REF_HAVE_OLD )
922- hashcpy ( update -> old_oid . hash , old_sha1 );
921+ oidcpy ( & update -> old_oid , old_oid );
923922 update -> msg = xstrdup_or_null (msg );
924923 return update ;
925924}
926925
927926int ref_transaction_update (struct ref_transaction * transaction ,
928927 const char * refname ,
929- const unsigned char * new_sha1 ,
930- const unsigned char * old_sha1 ,
928+ const struct object_id * new_oid ,
929+ const struct object_id * old_oid ,
931930 unsigned int flags , const char * msg ,
932931 struct strbuf * err )
933932{
934933 assert (err );
935934
936- if ((new_sha1 && !is_null_sha1 ( new_sha1 )) ?
935+ if ((new_oid && !is_null_oid ( new_oid )) ?
937936 check_refname_format (refname , REFNAME_ALLOW_ONELEVEL ) :
938937 !refname_is_safe (refname )) {
939938 strbuf_addf (err , "refusing to update ref with bad name '%s'" ,
@@ -943,48 +942,48 @@ int ref_transaction_update(struct ref_transaction *transaction,
943942
944943 flags &= REF_TRANSACTION_UPDATE_ALLOWED_FLAGS ;
945944
946- flags |= (new_sha1 ? REF_HAVE_NEW : 0 ) | (old_sha1 ? REF_HAVE_OLD : 0 );
945+ flags |= (new_oid ? REF_HAVE_NEW : 0 ) | (old_oid ? REF_HAVE_OLD : 0 );
947946
948947 ref_transaction_add_update (transaction , refname , flags ,
949- new_sha1 , old_sha1 , msg );
948+ new_oid , old_oid , msg );
950949 return 0 ;
951950}
952951
953952int ref_transaction_create (struct ref_transaction * transaction ,
954953 const char * refname ,
955- const unsigned char * new_sha1 ,
954+ const struct object_id * new_oid ,
956955 unsigned int flags , const char * msg ,
957956 struct strbuf * err )
958957{
959- if (!new_sha1 || is_null_sha1 ( new_sha1 ))
960- die ("BUG: create called without valid new_sha1 " );
961- return ref_transaction_update (transaction , refname , new_sha1 ,
962- null_sha1 , flags , msg , err );
958+ if (!new_oid || is_null_oid ( new_oid ))
959+ die ("BUG: create called without valid new_oid " );
960+ return ref_transaction_update (transaction , refname , new_oid ,
961+ & null_oid , flags , msg , err );
963962}
964963
965964int ref_transaction_delete (struct ref_transaction * transaction ,
966965 const char * refname ,
967- const unsigned char * old_sha1 ,
966+ const struct object_id * old_oid ,
968967 unsigned int flags , const char * msg ,
969968 struct strbuf * err )
970969{
971- if (old_sha1 && is_null_sha1 ( old_sha1 ))
972- die ("BUG: delete called with old_sha1 set to zeros" );
970+ if (old_oid && is_null_oid ( old_oid ))
971+ die ("BUG: delete called with old_oid set to zeros" );
973972 return ref_transaction_update (transaction , refname ,
974- null_sha1 , old_sha1 ,
973+ & null_oid , old_oid ,
975974 flags , msg , err );
976975}
977976
978977int ref_transaction_verify (struct ref_transaction * transaction ,
979978 const char * refname ,
980- const unsigned char * old_sha1 ,
979+ const struct object_id * old_oid ,
981980 unsigned int flags ,
982981 struct strbuf * err )
983982{
984- if (!old_sha1 )
985- die ("BUG: verify called with old_sha1 set to NULL" );
983+ if (!old_oid )
984+ die ("BUG: verify called with old_oid set to NULL" );
986985 return ref_transaction_update (transaction , refname ,
987- NULL , old_sha1 ,
986+ NULL , old_oid ,
988987 flags , NULL , err );
989988}
990989
@@ -1003,8 +1002,7 @@ int refs_update_ref(struct ref_store *refs, const char *msg,
10031002 } else {
10041003 t = ref_store_transaction_begin (refs , & err );
10051004 if (!t ||
1006- ref_transaction_update (t , refname , new_oid ? new_oid -> hash : NULL ,
1007- old_oid ? old_oid -> hash : NULL ,
1005+ ref_transaction_update (t , refname , new_oid , old_oid ,
10081006 flags , msg , & err ) ||
10091007 ref_transaction_commit (t , & err )) {
10101008 ret = 1 ;
0 commit comments