@@ -1267,6 +1267,7 @@ void ref_transaction_free(struct ref_transaction *transaction)
12671267 free (transaction -> updates [i ]-> committer_info );
12681268 free ((char * )transaction -> updates [i ]-> new_target );
12691269 free ((char * )transaction -> updates [i ]-> old_target );
1270+ free ((char * )transaction -> updates [i ]-> rejection_details );
12701271 free (transaction -> updates [i ]);
12711272 }
12721273
@@ -1281,7 +1282,8 @@ void ref_transaction_free(struct ref_transaction *transaction)
12811282
12821283int ref_transaction_maybe_set_rejected (struct ref_transaction * transaction ,
12831284 size_t update_idx ,
1284- enum ref_transaction_error err )
1285+ enum ref_transaction_error err ,
1286+ struct strbuf * details )
12851287{
12861288 if (update_idx >= transaction -> nr )
12871289 BUG ("trying to set rejection on invalid update index" );
@@ -1307,6 +1309,7 @@ int ref_transaction_maybe_set_rejected(struct ref_transaction *transaction,
13071309 transaction -> updates [update_idx ]-> refname , 0 );
13081310
13091311 transaction -> updates [update_idx ]-> rejection_err = err ;
1312+ transaction -> updates [update_idx ]-> rejection_details = strbuf_detach (details , NULL );
13101313 ALLOC_GROW (transaction -> rejections -> update_indices ,
13111314 transaction -> rejections -> nr + 1 ,
13121315 transaction -> rejections -> alloc );
@@ -2698,30 +2701,33 @@ enum ref_transaction_error refs_verify_refnames_available(struct ref_store *refs
26982701 if (!initial_transaction &&
26992702 (strset_contains (& conflicting_dirnames , dirname .buf ) ||
27002703 !refs_read_raw_ref (refs , dirname .buf , & oid , & referent ,
2701- & type , & ignore_errno ))) {
2704+ & type , & ignore_errno ))) {
2705+
2706+ strbuf_addf (err , _ ("'%s' exists; cannot create '%s'" ),
2707+ dirname .buf , refname );
2708+
27022709 if (transaction && ref_transaction_maybe_set_rejected (
27032710 transaction , * update_idx ,
2704- REF_TRANSACTION_ERROR_NAME_CONFLICT )) {
2711+ REF_TRANSACTION_ERROR_NAME_CONFLICT , err )) {
27052712 strset_remove (& dirnames , dirname .buf );
27062713 strset_add (& conflicting_dirnames , dirname .buf );
2707- continue ;
2714+ goto next_ref ;
27082715 }
27092716
2710- strbuf_addf (err , _ ("'%s' exists; cannot create '%s'" ),
2711- dirname .buf , refname );
27122717 goto cleanup ;
27132718 }
27142719
27152720 if (extras && string_list_has_string (extras , dirname .buf )) {
2721+ strbuf_addf (err , _ ("cannot process '%s' and '%s' at the same time" ),
2722+ refname , dirname .buf );
2723+
27162724 if (transaction && ref_transaction_maybe_set_rejected (
27172725 transaction , * update_idx ,
2718- REF_TRANSACTION_ERROR_NAME_CONFLICT )) {
2726+ REF_TRANSACTION_ERROR_NAME_CONFLICT , err )) {
27192727 strset_remove (& dirnames , dirname .buf );
2720- continue ;
2728+ goto next_ref ;
27212729 }
27222730
2723- strbuf_addf (err , _ ("cannot process '%s' and '%s' at the same time" ),
2724- refname , dirname .buf );
27252731 goto cleanup ;
27262732 }
27272733 }
@@ -2751,14 +2757,14 @@ enum ref_transaction_error refs_verify_refnames_available(struct ref_store *refs
27512757 if (skip &&
27522758 string_list_has_string (skip , iter -> ref .name ))
27532759 continue ;
2760+ strbuf_addf (err , _ ("'%s' exists; cannot create '%s'" ),
2761+ iter -> ref .name , refname );
27542762
27552763 if (transaction && ref_transaction_maybe_set_rejected (
27562764 transaction , * update_idx ,
2757- REF_TRANSACTION_ERROR_NAME_CONFLICT ))
2758- continue ;
2765+ REF_TRANSACTION_ERROR_NAME_CONFLICT , err ))
2766+ goto next_ref ;
27592767
2760- strbuf_addf (err , _ ("'%s' exists; cannot create '%s'" ),
2761- iter -> ref .name , refname );
27622768 goto cleanup ;
27632769 }
27642770
@@ -2768,15 +2774,17 @@ enum ref_transaction_error refs_verify_refnames_available(struct ref_store *refs
27682774
27692775 extra_refname = find_descendant_ref (dirname .buf , extras , skip );
27702776 if (extra_refname ) {
2777+ strbuf_addf (err , _ ("cannot process '%s' and '%s' at the same time" ),
2778+ refname , extra_refname );
2779+
27712780 if (transaction && ref_transaction_maybe_set_rejected (
27722781 transaction , * update_idx ,
2773- REF_TRANSACTION_ERROR_NAME_CONFLICT ))
2774- continue ;
2782+ REF_TRANSACTION_ERROR_NAME_CONFLICT , err ))
2783+ goto next_ref ;
27752784
2776- strbuf_addf (err , _ ("cannot process '%s' and '%s' at the same time" ),
2777- refname , extra_refname );
27782785 goto cleanup ;
27792786 }
2787+ next_ref :;
27802788 }
27812789
27822790 ret = 0 ;
@@ -2905,7 +2913,7 @@ void ref_transaction_for_each_rejected_update(struct ref_transaction *transactio
29052913 (update -> flags & REF_HAVE_OLD ) ? & update -> old_oid : NULL ,
29062914 (update -> flags & REF_HAVE_NEW ) ? & update -> new_oid : NULL ,
29072915 update -> old_target , update -> new_target ,
2908- update -> rejection_err , cb_data );
2916+ update -> rejection_err , update -> rejection_details , cb_data );
29092917 }
29102918}
29112919
0 commit comments