@@ -2378,9 +2378,7 @@ static struct ref_iterator *files_reflog_iterator_begin(struct ref_store *ref_st
23782378 */
23792379static int split_head_update (struct ref_update * update ,
23802380 struct ref_transaction * transaction ,
2381- const char * head_ref ,
2382- struct string_list * affected_refnames ,
2383- struct strbuf * err )
2381+ const char * head_ref , struct strbuf * err )
23842382{
23852383 struct ref_update * new_update ;
23862384
@@ -2398,7 +2396,7 @@ static int split_head_update(struct ref_update *update,
23982396 * transaction. This check is O(lg N) in the transaction
23992397 * size, but it happens at most once per transaction.
24002398 */
2401- if (string_list_has_string (affected_refnames , "HEAD" )) {
2399+ if (string_list_has_string (& transaction -> refnames , "HEAD" )) {
24022400 /* An entry already existed */
24032401 strbuf_addf (err ,
24042402 "multiple updates for 'HEAD' (including one "
@@ -2420,7 +2418,6 @@ static int split_head_update(struct ref_update *update,
24202418 */
24212419 if (strcmp (new_update -> refname , "HEAD" ))
24222420 BUG ("%s unexpectedly not 'HEAD'" , new_update -> refname );
2423- string_list_insert (affected_refnames , new_update -> refname );
24242421
24252422 return 0 ;
24262423}
@@ -2436,7 +2433,6 @@ static int split_head_update(struct ref_update *update,
24362433static int split_symref_update (struct ref_update * update ,
24372434 const char * referent ,
24382435 struct ref_transaction * transaction ,
2439- struct string_list * affected_refnames ,
24402436 struct strbuf * err )
24412437{
24422438 struct ref_update * new_update ;
@@ -2448,7 +2444,7 @@ static int split_symref_update(struct ref_update *update,
24482444 * size, but it happens at most once per symref in a
24492445 * transaction.
24502446 */
2451- if (string_list_has_string (affected_refnames , referent )) {
2447+ if (string_list_has_string (& transaction -> refnames , referent )) {
24522448 /* An entry already exists */
24532449 strbuf_addf (err ,
24542450 "multiple updates for '%s' (including one "
@@ -2486,15 +2482,6 @@ static int split_symref_update(struct ref_update *update,
24862482 update -> flags |= REF_LOG_ONLY | REF_NO_DEREF ;
24872483 update -> flags &= ~REF_HAVE_OLD ;
24882484
2489- /*
2490- * Add the referent. This insertion is O(N) in the transaction
2491- * size, but it happens at most once per symref in a
2492- * transaction. Make sure to add new_update->refname, which will
2493- * be valid as long as affected_refnames is in use, and NOT
2494- * referent, which might soon be freed by our caller.
2495- */
2496- string_list_insert (affected_refnames , new_update -> refname );
2497-
24982485 return 0 ;
24992486}
25002487
@@ -2558,7 +2545,6 @@ static int lock_ref_for_update(struct files_ref_store *refs,
25582545 struct ref_transaction * transaction ,
25592546 const char * head_ref ,
25602547 struct string_list * refnames_to_check ,
2561- struct string_list * affected_refnames ,
25622548 struct strbuf * err )
25632549{
25642550 struct strbuf referent = STRBUF_INIT ;
@@ -2575,8 +2561,7 @@ static int lock_ref_for_update(struct files_ref_store *refs,
25752561 update -> flags |= REF_DELETING ;
25762562
25772563 if (head_ref ) {
2578- ret = split_head_update (update , transaction , head_ref ,
2579- affected_refnames , err );
2564+ ret = split_head_update (update , transaction , head_ref , err );
25802565 if (ret )
25812566 goto out ;
25822567 }
@@ -2586,9 +2571,8 @@ static int lock_ref_for_update(struct files_ref_store *refs,
25862571 lock -> count ++ ;
25872572 } else {
25882573 ret = lock_raw_ref (refs , update -> refname , mustexist ,
2589- refnames_to_check , affected_refnames ,
2590- & lock , & referent ,
2591- & update -> type , err );
2574+ refnames_to_check , & transaction -> refnames ,
2575+ & lock , & referent , & update -> type , err );
25922576 if (ret ) {
25932577 char * reason ;
25942578
@@ -2642,9 +2626,8 @@ static int lock_ref_for_update(struct files_ref_store *refs,
26422626 * of processing the split-off update, so we
26432627 * don't have to do it here.
26442628 */
2645- ret = split_symref_update (update ,
2646- referent .buf , transaction ,
2647- affected_refnames , err );
2629+ ret = split_symref_update (update , referent .buf ,
2630+ transaction , err );
26482631 if (ret )
26492632 goto out ;
26502633 }
@@ -2799,7 +2782,6 @@ static int files_transaction_prepare(struct ref_store *ref_store,
27992782 "ref_transaction_prepare" );
28002783 size_t i ;
28012784 int ret = 0 ;
2802- struct string_list affected_refnames = STRING_LIST_INIT_NODUP ;
28032785 struct string_list refnames_to_check = STRING_LIST_INIT_NODUP ;
28042786 char * head_ref = NULL ;
28052787 int head_type ;
@@ -2818,29 +2800,14 @@ static int files_transaction_prepare(struct ref_store *ref_store,
28182800 transaction -> backend_data = backend_data ;
28192801
28202802 /*
2821- * Fail if a refname appears more than once in the
2822- * transaction. (If we end up splitting up any updates using
2823- * split_symref_update() or split_head_update(), those
2824- * functions will check that the new updates don't have the
2825- * same refname as any existing ones.) Also fail if any of the
2826- * updates use REF_IS_PRUNING without REF_NO_DEREF.
2803+ * Fail if any of the updates use REF_IS_PRUNING without REF_NO_DEREF.
28272804 */
28282805 for (i = 0 ; i < transaction -> nr ; i ++ ) {
28292806 struct ref_update * update = transaction -> updates [i ];
28302807
28312808 if ((update -> flags & REF_IS_PRUNING ) &&
28322809 !(update -> flags & REF_NO_DEREF ))
28332810 BUG ("REF_IS_PRUNING set without REF_NO_DEREF" );
2834-
2835- if (update -> flags & REF_LOG_ONLY )
2836- continue ;
2837-
2838- string_list_append (& affected_refnames , update -> refname );
2839- }
2840- string_list_sort (& affected_refnames );
2841- if (ref_update_reject_duplicates (& affected_refnames , err )) {
2842- ret = TRANSACTION_GENERIC_ERROR ;
2843- goto cleanup ;
28442811 }
28452812
28462813 /*
@@ -2882,7 +2849,7 @@ static int files_transaction_prepare(struct ref_store *ref_store,
28822849
28832850 ret = lock_ref_for_update (refs , update , transaction ,
28842851 head_ref , & refnames_to_check ,
2885- & affected_refnames , err );
2852+ err );
28862853 if (ret )
28872854 goto cleanup ;
28882855
@@ -2929,7 +2896,7 @@ static int files_transaction_prepare(struct ref_store *ref_store,
29292896 * So instead, we accept the race for now.
29302897 */
29312898 if (refs_verify_refnames_available (refs -> packed_ref_store , & refnames_to_check ,
2932- & affected_refnames , NULL , 0 , err )) {
2899+ & transaction -> refnames , NULL , 0 , err )) {
29332900 ret = TRANSACTION_NAME_CONFLICT ;
29342901 goto cleanup ;
29352902 }
@@ -2975,7 +2942,6 @@ static int files_transaction_prepare(struct ref_store *ref_store,
29752942
29762943cleanup :
29772944 free (head_ref );
2978- string_list_clear (& affected_refnames , 0 );
29792945 string_list_clear (& refnames_to_check , 0 );
29802946
29812947 if (ret )
@@ -3050,13 +3016,8 @@ static int files_transaction_finish_initial(struct files_ref_store *refs,
30503016 if (transaction -> state != REF_TRANSACTION_PREPARED )
30513017 BUG ("commit called for transaction that is not prepared" );
30523018
3053- /* Fail if a refname appears more than once in the transaction: */
3054- for (i = 0 ; i < transaction -> nr ; i ++ )
3055- if (!(transaction -> updates [i ]-> flags & REF_LOG_ONLY ))
3056- string_list_append (& affected_refnames ,
3057- transaction -> updates [i ]-> refname );
3058- string_list_sort (& affected_refnames );
3059- if (ref_update_reject_duplicates (& affected_refnames , err )) {
3019+ string_list_sort (& transaction -> refnames );
3020+ if (ref_update_reject_duplicates (& transaction -> refnames , err )) {
30603021 ret = TRANSACTION_GENERIC_ERROR ;
30613022 goto cleanup ;
30623023 }
@@ -3074,7 +3035,7 @@ static int files_transaction_finish_initial(struct files_ref_store *refs,
30743035 * that we are creating already exists.
30753036 */
30763037 if (refs_for_each_rawref (& refs -> base , ref_present ,
3077- & affected_refnames ))
3038+ & transaction -> refnames ))
30783039 BUG ("initial ref transaction called with existing refs" );
30793040
30803041 packed_transaction = ref_store_transaction_begin (refs -> packed_ref_store ,
0 commit comments