@@ -2378,9 +2378,7 @@ static struct ref_iterator *files_reflog_iterator_begin(struct ref_store *ref_st
2378
2378
*/
2379
2379
static int split_head_update (struct ref_update * update ,
2380
2380
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 )
2384
2382
{
2385
2383
struct ref_update * new_update ;
2386
2384
@@ -2398,7 +2396,7 @@ static int split_head_update(struct ref_update *update,
2398
2396
* transaction. This check is O(lg N) in the transaction
2399
2397
* size, but it happens at most once per transaction.
2400
2398
*/
2401
- if (string_list_has_string (affected_refnames , "HEAD" )) {
2399
+ if (string_list_has_string (& transaction -> refnames , "HEAD" )) {
2402
2400
/* An entry already existed */
2403
2401
strbuf_addf (err ,
2404
2402
"multiple updates for 'HEAD' (including one "
@@ -2420,7 +2418,6 @@ static int split_head_update(struct ref_update *update,
2420
2418
*/
2421
2419
if (strcmp (new_update -> refname , "HEAD" ))
2422
2420
BUG ("%s unexpectedly not 'HEAD'" , new_update -> refname );
2423
- string_list_insert (affected_refnames , new_update -> refname );
2424
2421
2425
2422
return 0 ;
2426
2423
}
@@ -2436,7 +2433,6 @@ static int split_head_update(struct ref_update *update,
2436
2433
static int split_symref_update (struct ref_update * update ,
2437
2434
const char * referent ,
2438
2435
struct ref_transaction * transaction ,
2439
- struct string_list * affected_refnames ,
2440
2436
struct strbuf * err )
2441
2437
{
2442
2438
struct ref_update * new_update ;
@@ -2448,7 +2444,7 @@ static int split_symref_update(struct ref_update *update,
2448
2444
* size, but it happens at most once per symref in a
2449
2445
* transaction.
2450
2446
*/
2451
- if (string_list_has_string (affected_refnames , referent )) {
2447
+ if (string_list_has_string (& transaction -> refnames , referent )) {
2452
2448
/* An entry already exists */
2453
2449
strbuf_addf (err ,
2454
2450
"multiple updates for '%s' (including one "
@@ -2486,15 +2482,6 @@ static int split_symref_update(struct ref_update *update,
2486
2482
update -> flags |= REF_LOG_ONLY | REF_NO_DEREF ;
2487
2483
update -> flags &= ~REF_HAVE_OLD ;
2488
2484
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
-
2498
2485
return 0 ;
2499
2486
}
2500
2487
@@ -2558,7 +2545,6 @@ static int lock_ref_for_update(struct files_ref_store *refs,
2558
2545
struct ref_transaction * transaction ,
2559
2546
const char * head_ref ,
2560
2547
struct string_list * refnames_to_check ,
2561
- struct string_list * affected_refnames ,
2562
2548
struct strbuf * err )
2563
2549
{
2564
2550
struct strbuf referent = STRBUF_INIT ;
@@ -2575,8 +2561,7 @@ static int lock_ref_for_update(struct files_ref_store *refs,
2575
2561
update -> flags |= REF_DELETING ;
2576
2562
2577
2563
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 );
2580
2565
if (ret )
2581
2566
goto out ;
2582
2567
}
@@ -2586,9 +2571,8 @@ static int lock_ref_for_update(struct files_ref_store *refs,
2586
2571
lock -> count ++ ;
2587
2572
} else {
2588
2573
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 );
2592
2576
if (ret ) {
2593
2577
char * reason ;
2594
2578
@@ -2642,9 +2626,8 @@ static int lock_ref_for_update(struct files_ref_store *refs,
2642
2626
* of processing the split-off update, so we
2643
2627
* don't have to do it here.
2644
2628
*/
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 );
2648
2631
if (ret )
2649
2632
goto out ;
2650
2633
}
@@ -2799,7 +2782,6 @@ static int files_transaction_prepare(struct ref_store *ref_store,
2799
2782
"ref_transaction_prepare" );
2800
2783
size_t i ;
2801
2784
int ret = 0 ;
2802
- struct string_list affected_refnames = STRING_LIST_INIT_NODUP ;
2803
2785
struct string_list refnames_to_check = STRING_LIST_INIT_NODUP ;
2804
2786
char * head_ref = NULL ;
2805
2787
int head_type ;
@@ -2818,29 +2800,14 @@ static int files_transaction_prepare(struct ref_store *ref_store,
2818
2800
transaction -> backend_data = backend_data ;
2819
2801
2820
2802
/*
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.
2827
2804
*/
2828
2805
for (i = 0 ; i < transaction -> nr ; i ++ ) {
2829
2806
struct ref_update * update = transaction -> updates [i ];
2830
2807
2831
2808
if ((update -> flags & REF_IS_PRUNING ) &&
2832
2809
!(update -> flags & REF_NO_DEREF ))
2833
2810
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 ;
2844
2811
}
2845
2812
2846
2813
/*
@@ -2882,7 +2849,7 @@ static int files_transaction_prepare(struct ref_store *ref_store,
2882
2849
2883
2850
ret = lock_ref_for_update (refs , update , transaction ,
2884
2851
head_ref , & refnames_to_check ,
2885
- & affected_refnames , err );
2852
+ err );
2886
2853
if (ret )
2887
2854
goto cleanup ;
2888
2855
@@ -2929,7 +2896,7 @@ static int files_transaction_prepare(struct ref_store *ref_store,
2929
2896
* So instead, we accept the race for now.
2930
2897
*/
2931
2898
if (refs_verify_refnames_available (refs -> packed_ref_store , & refnames_to_check ,
2932
- & affected_refnames , NULL , 0 , err )) {
2899
+ & transaction -> refnames , NULL , 0 , err )) {
2933
2900
ret = TRANSACTION_NAME_CONFLICT ;
2934
2901
goto cleanup ;
2935
2902
}
@@ -2975,7 +2942,6 @@ static int files_transaction_prepare(struct ref_store *ref_store,
2975
2942
2976
2943
cleanup :
2977
2944
free (head_ref );
2978
- string_list_clear (& affected_refnames , 0 );
2979
2945
string_list_clear (& refnames_to_check , 0 );
2980
2946
2981
2947
if (ret )
@@ -3050,13 +3016,8 @@ static int files_transaction_finish_initial(struct files_ref_store *refs,
3050
3016
if (transaction -> state != REF_TRANSACTION_PREPARED )
3051
3017
BUG ("commit called for transaction that is not prepared" );
3052
3018
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 )) {
3060
3021
ret = TRANSACTION_GENERIC_ERROR ;
3061
3022
goto cleanup ;
3062
3023
}
@@ -3074,7 +3035,7 @@ static int files_transaction_finish_initial(struct files_ref_store *refs,
3074
3035
* that we are creating already exists.
3075
3036
*/
3076
3037
if (refs_for_each_rawref (& refs -> base , ref_present ,
3077
- & affected_refnames ))
3038
+ & transaction -> refnames ))
3078
3039
BUG ("initial ref transaction called with existing refs" );
3079
3040
3080
3041
packed_transaction = ref_store_transaction_begin (refs -> packed_ref_store ,
0 commit comments