@@ -238,24 +238,20 @@ struct rename {
238
238
239
239
struct rename_conflict_info {
240
240
enum rename_type rename_type ;
241
- struct diff_filepair * pair1 ;
242
- struct diff_filepair * pair2 ;
241
+ struct rename * ren1 ;
242
+ struct rename * ren2 ;
243
243
const char * branch1 ;
244
244
const char * branch2 ;
245
- struct stage_data * dst_entry1 ;
246
- struct stage_data * dst_entry2 ;
247
245
struct diff_filespec ren1_other ;
248
246
struct diff_filespec ren2_other ;
249
247
};
250
248
251
249
static inline void setup_rename_conflict_info (enum rename_type rename_type ,
252
- struct diff_filepair * pair1 ,
253
- struct diff_filepair * pair2 ,
250
+ struct merge_options * opt ,
251
+ struct rename * ren1 ,
252
+ struct rename * ren2 ,
254
253
const char * branch1 ,
255
254
const char * branch2 ,
256
- struct stage_data * dst_entry1 ,
257
- struct stage_data * dst_entry2 ,
258
- struct merge_options * opt ,
259
255
struct stage_data * src_entry1 ,
260
256
struct stage_data * src_entry2 )
261
257
{
@@ -269,31 +265,27 @@ static inline void setup_rename_conflict_info(enum rename_type rename_type,
269
265
* ensure that branch1 == opt->branch1. So, simply flip arguments
270
266
* around if we don't have that.
271
267
*/
272
- if (dst_entry2 && branch1 != opt -> branch1 ) {
268
+ if (ren2 && branch1 != opt -> branch1 ) {
273
269
setup_rename_conflict_info (rename_type ,
274
- pair2 , pair1 ,
275
- branch2 , branch1 ,
276
- dst_entry2 , dst_entry1 ,
277
270
opt ,
271
+ ren2 , ren1 ,
272
+ branch2 , branch1 ,
278
273
src_entry2 , src_entry1 );
279
274
return ;
280
275
}
281
276
282
277
ci = xcalloc (1 , sizeof (struct rename_conflict_info ));
283
278
ci -> rename_type = rename_type ;
284
- ci -> pair1 = pair1 ;
279
+ ci -> ren1 = ren1 ;
280
+ ci -> ren2 = ren2 ;
285
281
ci -> branch1 = branch1 ;
286
282
ci -> branch2 = branch2 ;
287
283
288
- ci -> dst_entry1 = dst_entry1 ;
289
- dst_entry1 -> rename_conflict_info = ci ;
290
- dst_entry1 -> processed = 0 ;
284
+ ci -> ren1 -> dst_entry -> processed = 0 ;
285
+ ci -> ren1 -> dst_entry -> rename_conflict_info = ci ;
291
286
292
- assert (!pair2 == !dst_entry2 );
293
- if (dst_entry2 ) {
294
- ci -> dst_entry2 = dst_entry2 ;
295
- ci -> pair2 = pair2 ;
296
- dst_entry2 -> rename_conflict_info = ci ;
287
+ if (ren2 ) {
288
+ ci -> ren2 -> dst_entry -> rename_conflict_info = ci ;
297
289
}
298
290
299
291
/*
@@ -305,15 +297,15 @@ static inline void setup_rename_conflict_info(enum rename_type rename_type,
305
297
rename_type == RENAME_TWO_FILES_TO_ONE ) {
306
298
ostage1 = opt -> branch1 == branch1 ? 3 : 2 ;
307
299
308
- ci -> ren1_other .path = pair1 -> one -> path ;
300
+ ci -> ren1_other .path = ren1 -> pair -> one -> path ;
309
301
oidcpy (& ci -> ren1_other .oid , & src_entry1 -> stages [ostage1 ].oid );
310
302
ci -> ren1_other .mode = src_entry1 -> stages [ostage1 ].mode ;
311
303
}
312
304
313
305
if (rename_type == RENAME_TWO_FILES_TO_ONE ) {
314
306
ostage2 = ostage1 ^ 1 ;
315
307
316
- ci -> ren2_other .path = pair2 -> one -> path ;
308
+ ci -> ren2_other .path = ren2 -> pair -> one -> path ;
317
309
oidcpy (& ci -> ren2_other .oid , & src_entry2 -> stages [ostage2 ].oid );
318
310
ci -> ren2_other .mode = src_entry2 -> stages [ostage2 ].mode ;
319
311
}
@@ -1694,8 +1686,8 @@ static int handle_rename_add(struct merge_options *opt,
1694
1686
struct rename_conflict_info * ci )
1695
1687
{
1696
1688
/* a was renamed to c, and a separate c was added. */
1697
- struct diff_filespec * a = ci -> pair1 -> one ;
1698
- struct diff_filespec * c = ci -> pair1 -> two ;
1689
+ struct diff_filespec * a = ci -> ren1 -> pair -> one ;
1690
+ struct diff_filespec * c = ci -> ren1 -> pair -> two ;
1699
1691
char * path = c -> path ;
1700
1692
char * prev_path_desc ;
1701
1693
struct merge_file_info mfi ;
@@ -1718,8 +1710,8 @@ static int handle_rename_add(struct merge_options *opt,
1718
1710
c -> path , a -> path , NULL ,
1719
1711
ci -> branch1 , ci -> branch2 ,
1720
1712
& mfi .oid , mfi .mode ,
1721
- & ci -> dst_entry1 -> stages [other_stage ].oid ,
1722
- ci -> dst_entry1 -> stages [other_stage ].mode );
1713
+ & ci -> ren1 -> dst_entry -> stages [other_stage ].oid ,
1714
+ ci -> ren1 -> dst_entry -> stages [other_stage ].mode );
1723
1715
}
1724
1716
1725
1717
static char * find_path_for_conflict (struct merge_options * opt ,
@@ -1750,9 +1742,9 @@ static int handle_rename_rename_1to2(struct merge_options *opt,
1750
1742
struct merge_file_info mfi ;
1751
1743
struct diff_filespec other ;
1752
1744
struct diff_filespec * add ;
1753
- struct diff_filespec * o = ci -> pair1 -> one ;
1754
- struct diff_filespec * a = ci -> pair1 -> two ;
1755
- struct diff_filespec * b = ci -> pair2 -> two ;
1745
+ struct diff_filespec * o = ci -> ren1 -> pair -> one ;
1746
+ struct diff_filespec * a = ci -> ren1 -> pair -> two ;
1747
+ struct diff_filespec * b = ci -> ren2 -> pair -> two ;
1756
1748
char * path_desc ;
1757
1749
1758
1750
output (opt , 1 , _ ("CONFLICT (rename/rename): "
@@ -1788,14 +1780,14 @@ static int handle_rename_rename_1to2(struct merge_options *opt,
1788
1780
* such cases, we should keep the added file around,
1789
1781
* resolving the conflict at that path in its favor.
1790
1782
*/
1791
- add = filespec_from_entry (& other , ci -> dst_entry1 , 2 ^ 1 );
1783
+ add = filespec_from_entry (& other , ci -> ren1 -> dst_entry , 2 ^ 1 );
1792
1784
if (add ) {
1793
1785
if (update_file (opt , 0 , & add -> oid , add -> mode , a -> path ))
1794
1786
return -1 ;
1795
1787
}
1796
1788
else
1797
1789
remove_file_from_index (opt -> repo -> index , a -> path );
1798
- add = filespec_from_entry (& other , ci -> dst_entry2 , 3 ^ 1 );
1790
+ add = filespec_from_entry (& other , ci -> ren2 -> dst_entry , 3 ^ 1 );
1799
1791
if (add ) {
1800
1792
if (update_file (opt , 0 , & add -> oid , add -> mode , b -> path ))
1801
1793
return -1 ;
@@ -1808,7 +1800,7 @@ static int handle_rename_rename_1to2(struct merge_options *opt,
1808
1800
* rename/add collision. If not, we can write the file out
1809
1801
* to the specified location.
1810
1802
*/
1811
- add = filespec_from_entry (& other , ci -> dst_entry1 , 2 ^ 1 );
1803
+ add = filespec_from_entry (& other , ci -> ren1 -> dst_entry , 2 ^ 1 );
1812
1804
if (add ) {
1813
1805
if (handle_file_collision (opt , a -> path ,
1814
1806
NULL , NULL ,
@@ -1827,7 +1819,7 @@ static int handle_rename_rename_1to2(struct merge_options *opt,
1827
1819
return -1 ;
1828
1820
}
1829
1821
1830
- add = filespec_from_entry (& other , ci -> dst_entry2 , 3 ^ 1 );
1822
+ add = filespec_from_entry (& other , ci -> ren2 -> dst_entry , 3 ^ 1 );
1831
1823
if (add ) {
1832
1824
if (handle_file_collision (opt , b -> path ,
1833
1825
NULL , NULL ,
@@ -1854,10 +1846,10 @@ static int handle_rename_rename_2to1(struct merge_options *opt,
1854
1846
struct rename_conflict_info * ci )
1855
1847
{
1856
1848
/* Two files, a & b, were renamed to the same thing, c. */
1857
- struct diff_filespec * a = ci -> pair1 -> one ;
1858
- struct diff_filespec * b = ci -> pair2 -> one ;
1859
- struct diff_filespec * c1 = ci -> pair1 -> two ;
1860
- struct diff_filespec * c2 = ci -> pair2 -> two ;
1849
+ struct diff_filespec * a = ci -> ren1 -> pair -> one ;
1850
+ struct diff_filespec * b = ci -> ren2 -> pair -> one ;
1851
+ struct diff_filespec * c1 = ci -> ren1 -> pair -> two ;
1852
+ struct diff_filespec * c2 = ci -> ren2 -> pair -> two ;
1861
1853
char * path = c1 -> path ; /* == c2->path */
1862
1854
char * path_side_1_desc ;
1863
1855
char * path_side_2_desc ;
@@ -2732,13 +2724,11 @@ static int process_renames(struct merge_options *opt,
2732
2724
ren2 -> pair -> two );
2733
2725
}
2734
2726
setup_rename_conflict_info (rename_type ,
2735
- ren1 -> pair ,
2736
- ren2 -> pair ,
2727
+ opt ,
2728
+ ren1 ,
2729
+ ren2 ,
2737
2730
branch1 ,
2738
2731
branch2 ,
2739
- ren1 -> dst_entry ,
2740
- ren2 -> dst_entry ,
2741
- opt ,
2742
2732
NULL ,
2743
2733
NULL );
2744
2734
} else if ((lookup = string_list_lookup (renames2Dst , ren1_dst ))) {
@@ -2759,13 +2749,11 @@ static int process_renames(struct merge_options *opt,
2759
2749
ren2 -> src_entry -> processed = 1 ;
2760
2750
2761
2751
setup_rename_conflict_info (RENAME_TWO_FILES_TO_ONE ,
2762
- ren1 -> pair ,
2763
- ren2 -> pair ,
2752
+ opt ,
2753
+ ren1 ,
2754
+ ren2 ,
2764
2755
branch1 ,
2765
2756
branch2 ,
2766
- ren1 -> dst_entry ,
2767
- ren2 -> dst_entry ,
2768
- opt ,
2769
2757
ren1 -> src_entry ,
2770
2758
ren2 -> src_entry );
2771
2759
@@ -2802,24 +2790,20 @@ static int process_renames(struct merge_options *opt,
2802
2790
if (oid_eq (& src_other .oid , & null_oid ) &&
2803
2791
ren1 -> add_turned_into_rename ) {
2804
2792
setup_rename_conflict_info (RENAME_VIA_DIR ,
2805
- ren1 -> pair ,
2793
+ opt ,
2794
+ ren1 ,
2806
2795
NULL ,
2807
2796
branch1 ,
2808
2797
branch2 ,
2809
- ren1 -> dst_entry ,
2810
- NULL ,
2811
- opt ,
2812
2798
NULL ,
2813
2799
NULL );
2814
2800
} else if (oid_eq (& src_other .oid , & null_oid )) {
2815
2801
setup_rename_conflict_info (RENAME_DELETE ,
2816
- ren1 -> pair ,
2802
+ opt ,
2803
+ ren1 ,
2817
2804
NULL ,
2818
2805
branch1 ,
2819
2806
branch2 ,
2820
- ren1 -> dst_entry ,
2821
- NULL ,
2822
- opt ,
2823
2807
NULL ,
2824
2808
NULL );
2825
2809
} else if ((dst_other .mode == ren1 -> pair -> two -> mode ) &&
@@ -2848,13 +2832,11 @@ static int process_renames(struct merge_options *opt,
2848
2832
* file, then the merge will be clean.
2849
2833
*/
2850
2834
setup_rename_conflict_info (RENAME_ADD ,
2851
- ren1 -> pair ,
2835
+ opt ,
2836
+ ren1 ,
2852
2837
NULL ,
2853
2838
branch1 ,
2854
2839
branch2 ,
2855
- ren1 -> dst_entry ,
2856
- NULL ,
2857
- opt ,
2858
2840
ren1 -> src_entry ,
2859
2841
NULL );
2860
2842
} else
@@ -2876,13 +2858,11 @@ static int process_renames(struct merge_options *opt,
2876
2858
}
2877
2859
update_entry (ren1 -> dst_entry , o , a , b );
2878
2860
setup_rename_conflict_info (RENAME_NORMAL ,
2879
- ren1 -> pair ,
2861
+ opt ,
2862
+ ren1 ,
2880
2863
NULL ,
2881
2864
branch1 ,
2882
2865
NULL ,
2883
- ren1 -> dst_entry ,
2884
- NULL ,
2885
- opt ,
2886
2866
NULL ,
2887
2867
NULL );
2888
2868
}
@@ -3119,15 +3099,15 @@ static int handle_content_merge(struct merge_options *opt,
3119
3099
b .mode = b_mode ;
3120
3100
3121
3101
if (ci ) {
3122
- struct diff_filepair * pair1 = ci -> pair1 ;
3102
+ struct diff_filepair * pair1 = ci -> ren1 -> pair ;
3123
3103
3124
3104
path1 = (opt -> branch1 == ci -> branch1 ) ?
3125
3105
pair1 -> two -> path : pair1 -> one -> path ;
3126
- /* If ci->pair2 != NULL, we are in
3106
+ /* If ci->ren2->pair != NULL, we are in
3127
3107
* RENAME_ONE_FILE_TO_ONE case. Otherwise, we have a
3128
3108
* normal rename.
3129
3109
*/
3130
- path2 = (ci -> pair2 ||
3110
+ path2 = (( ci -> ren2 && ci -> ren2 -> pair ) ||
3131
3111
opt -> branch2 == ci -> branch1 ) ?
3132
3112
pair1 -> two -> path : pair1 -> one -> path ;
3133
3113
one .path = pair1 -> one -> path ;
@@ -3264,7 +3244,7 @@ static int process_entry(struct merge_options *opt,
3264
3244
break ;
3265
3245
case RENAME_VIA_DIR :
3266
3246
clean_merge = 1 ;
3267
- if (handle_rename_via_dir (opt , ci -> pair1 , ci -> branch1 ))
3247
+ if (handle_rename_via_dir (opt , ci -> ren1 -> pair , ci -> branch1 ))
3268
3248
clean_merge = -1 ;
3269
3249
break ;
3270
3250
case RENAME_ADD :
@@ -3278,7 +3258,7 @@ static int process_entry(struct merge_options *opt,
3278
3258
break ;
3279
3259
case RENAME_DELETE :
3280
3260
clean_merge = 0 ;
3281
- if (handle_rename_delete (opt , ci -> pair1 ,
3261
+ if (handle_rename_delete (opt , ci -> ren1 -> pair ,
3282
3262
ci -> branch1 , ci -> branch2 ))
3283
3263
clean_merge = -1 ;
3284
3264
break ;
0 commit comments