@@ -1274,14 +1274,14 @@ static int merge_submodule(struct merge_options *o,
1274
1274
return 0 ;
1275
1275
}
1276
1276
1277
- static int merge_file_1 (struct merge_options * o ,
1278
- const struct diff_filespec * one ,
1279
- const struct diff_filespec * a ,
1280
- const struct diff_filespec * b ,
1281
- const char * filename ,
1282
- const char * branch1 ,
1283
- const char * branch2 ,
1284
- struct merge_file_info * result )
1277
+ static int merge_mode_and_contents (struct merge_options * o ,
1278
+ const struct diff_filespec * one ,
1279
+ const struct diff_filespec * a ,
1280
+ const struct diff_filespec * b ,
1281
+ const char * filename ,
1282
+ const char * branch1 ,
1283
+ const char * branch2 ,
1284
+ struct merge_file_info * result )
1285
1285
{
1286
1286
result -> merge = 0 ;
1287
1287
result -> clean = 1 ;
@@ -1366,56 +1366,6 @@ static int merge_file_1(struct merge_options *o,
1366
1366
return 0 ;
1367
1367
}
1368
1368
1369
- static int merge_file_special_markers (struct merge_options * o ,
1370
- const struct diff_filespec * one ,
1371
- const struct diff_filespec * a ,
1372
- const struct diff_filespec * b ,
1373
- const char * target_filename ,
1374
- const char * branch1 ,
1375
- const char * filename1 ,
1376
- const char * branch2 ,
1377
- const char * filename2 ,
1378
- struct merge_file_info * mfi )
1379
- {
1380
- char * side1 = NULL ;
1381
- char * side2 = NULL ;
1382
- int ret ;
1383
-
1384
- if (filename1 )
1385
- side1 = xstrfmt ("%s:%s" , branch1 , filename1 );
1386
- if (filename2 )
1387
- side2 = xstrfmt ("%s:%s" , branch2 , filename2 );
1388
-
1389
- ret = merge_file_1 (o , one , a , b , target_filename ,
1390
- side1 ? side1 : branch1 ,
1391
- side2 ? side2 : branch2 , mfi );
1392
-
1393
- free (side1 );
1394
- free (side2 );
1395
- return ret ;
1396
- }
1397
-
1398
- static int merge_file_one (struct merge_options * o ,
1399
- const char * path ,
1400
- const struct object_id * o_oid , int o_mode ,
1401
- const struct object_id * a_oid , int a_mode ,
1402
- const struct object_id * b_oid , int b_mode ,
1403
- const char * branch1 ,
1404
- const char * branch2 ,
1405
- struct merge_file_info * mfi )
1406
- {
1407
- struct diff_filespec one , a , b ;
1408
-
1409
- one .path = a .path = b .path = (char * )path ;
1410
- oidcpy (& one .oid , o_oid );
1411
- one .mode = o_mode ;
1412
- oidcpy (& a .oid , a_oid );
1413
- a .mode = a_mode ;
1414
- oidcpy (& b .oid , b_oid );
1415
- b .mode = b_mode ;
1416
- return merge_file_1 (o , & one , & a , & b , path , branch1 , branch2 , mfi );
1417
- }
1418
-
1419
1369
static int handle_rename_via_dir (struct merge_options * o ,
1420
1370
struct diff_filepair * pair ,
1421
1371
const char * rename_branch ,
@@ -1659,11 +1609,8 @@ static int handle_rename_rename_1to2(struct merge_options *o,
1659
1609
struct merge_file_info mfi ;
1660
1610
struct diff_filespec other ;
1661
1611
struct diff_filespec * add ;
1662
- if (merge_file_one (o , one -> path ,
1663
- & one -> oid , one -> mode ,
1664
- & a -> oid , a -> mode ,
1665
- & b -> oid , b -> mode ,
1666
- ci -> branch1 , ci -> branch2 , & mfi ))
1612
+ if (merge_mode_and_contents (o , one , a , b , one -> path ,
1613
+ ci -> branch1 , ci -> branch2 , & mfi ))
1667
1614
return -1 ;
1668
1615
1669
1616
/*
@@ -1729,14 +1676,10 @@ static int handle_rename_rename_2to1(struct merge_options *o,
1729
1676
1730
1677
path_side_1_desc = xstrfmt ("%s (was %s)" , path , a -> path );
1731
1678
path_side_2_desc = xstrfmt ("%s (was %s)" , path , b -> path );
1732
- if (merge_file_special_markers (o , a , c1 , & ci -> ren1_other ,
1733
- path_side_1_desc ,
1734
- o -> branch1 , c1 -> path ,
1735
- o -> branch2 , ci -> ren1_other .path , & mfi_c1 ) ||
1736
- merge_file_special_markers (o , b , & ci -> ren2_other , c2 ,
1737
- path_side_2_desc ,
1738
- o -> branch1 , ci -> ren2_other .path ,
1739
- o -> branch2 , c2 -> path , & mfi_c2 ))
1679
+ if (merge_mode_and_contents (o , a , c1 , & ci -> ren1_other , path_side_1_desc ,
1680
+ o -> branch1 , o -> branch2 , & mfi_c1 ) ||
1681
+ merge_mode_and_contents (o , b , & ci -> ren2_other , c2 , path_side_2_desc ,
1682
+ o -> branch1 , o -> branch2 , & mfi_c2 ))
1740
1683
return -1 ;
1741
1684
free (path_side_1_desc );
1742
1685
free (path_side_2_desc );
@@ -2766,12 +2709,23 @@ static int process_renames(struct merge_options *o,
2766
2709
ren1_dst , branch2 );
2767
2710
if (o -> call_depth ) {
2768
2711
struct merge_file_info mfi ;
2769
- if (merge_file_one (o , ren1_dst , & null_oid , 0 ,
2770
- & ren1 -> pair -> two -> oid ,
2771
- ren1 -> pair -> two -> mode ,
2772
- & dst_other .oid ,
2773
- dst_other .mode ,
2774
- branch1 , branch2 , & mfi )) {
2712
+ struct diff_filespec one , a , b ;
2713
+
2714
+ oidcpy (& one .oid , & null_oid );
2715
+ one .mode = 0 ;
2716
+ one .path = ren1 -> pair -> two -> path ;
2717
+
2718
+ oidcpy (& a .oid , & ren1 -> pair -> two -> oid );
2719
+ a .mode = ren1 -> pair -> two -> mode ;
2720
+ a .path = one .path ;
2721
+
2722
+ oidcpy (& b .oid , & dst_other .oid );
2723
+ b .mode = dst_other .mode ;
2724
+ b .path = one .path ;
2725
+
2726
+ if (merge_mode_and_contents (o , & one , & a , & b , ren1_dst ,
2727
+ branch1 , branch2 ,
2728
+ & mfi )) {
2775
2729
clean_merge = -1 ;
2776
2730
goto cleanup_and_return ;
2777
2731
}
@@ -3021,13 +2975,13 @@ static int handle_modify_delete(struct merge_options *o,
3021
2975
_ ("modify" ), _ ("modified" ));
3022
2976
}
3023
2977
3024
- static int merge_content (struct merge_options * o ,
3025
- const char * path ,
3026
- int is_dirty ,
3027
- struct object_id * o_oid , int o_mode ,
3028
- struct object_id * a_oid , int a_mode ,
3029
- struct object_id * b_oid , int b_mode ,
3030
- struct rename_conflict_info * rename_conflict_info )
2978
+ static int handle_content_merge (struct merge_options * o ,
2979
+ const char * path ,
2980
+ int is_dirty ,
2981
+ struct object_id * o_oid , int o_mode ,
2982
+ struct object_id * a_oid , int a_mode ,
2983
+ struct object_id * b_oid , int b_mode ,
2984
+ struct rename_conflict_info * rename_conflict_info )
3031
2985
{
3032
2986
const char * reason = _ ("content" );
3033
2987
const char * path1 = NULL , * path2 = NULL ;
@@ -3059,14 +3013,16 @@ static int merge_content(struct merge_options *o,
3059
3013
path2 = (rename_conflict_info -> pair2 ||
3060
3014
o -> branch2 == rename_conflict_info -> branch1 ) ?
3061
3015
pair1 -> two -> path : pair1 -> one -> path ;
3016
+ one .path = pair1 -> one -> path ;
3017
+ a .path = (char * )path1 ;
3018
+ b .path = (char * )path2 ;
3062
3019
3063
3020
if (dir_in_way (path , !o -> call_depth ,
3064
3021
S_ISGITLINK (pair1 -> two -> mode )))
3065
3022
df_conflict_remains = 1 ;
3066
3023
}
3067
- if (merge_file_special_markers (o , & one , & a , & b , path ,
3068
- o -> branch1 , path1 ,
3069
- o -> branch2 , path2 , & mfi ))
3024
+ if (merge_mode_and_contents (o , & one , & a , & b , path ,
3025
+ o -> branch1 , o -> branch2 , & mfi ))
3070
3026
return -1 ;
3071
3027
3072
3028
/*
@@ -3157,9 +3113,9 @@ static int handle_rename_normal(struct merge_options *o,
3157
3113
struct rename_conflict_info * ci )
3158
3114
{
3159
3115
/* Merge the content and write it out */
3160
- return merge_content (o , path , was_dirty (o , path ),
3161
- o_oid , o_mode , a_oid , a_mode , b_oid , b_mode ,
3162
- ci );
3116
+ return handle_content_merge (o , path , was_dirty (o , path ),
3117
+ o_oid , o_mode , a_oid , a_mode , b_oid , b_mode ,
3118
+ ci );
3163
3119
}
3164
3120
3165
3121
/* Per entry merge function */
@@ -3283,9 +3239,11 @@ static int process_entry(struct merge_options *o,
3283
3239
/* Case C: Added in both (check for same permissions) and */
3284
3240
/* case D: Modified in both, but differently. */
3285
3241
int is_dirty = 0 ; /* unpack_trees would have bailed if dirty */
3286
- clean_merge = merge_content (o , path , is_dirty ,
3287
- o_oid , o_mode , a_oid , a_mode , b_oid , b_mode ,
3288
- NULL );
3242
+ clean_merge = handle_content_merge (o , path , is_dirty ,
3243
+ o_oid , o_mode ,
3244
+ a_oid , a_mode ,
3245
+ b_oid , b_mode ,
3246
+ NULL );
3289
3247
} else if (!o_oid && !a_oid && !b_oid ) {
3290
3248
/*
3291
3249
* this entry was deleted altogether. a_mode == 0 means
0 commit comments