@@ -1274,14 +1274,14 @@ static int merge_submodule(struct merge_options *o,
12741274 return 0 ;
12751275}
12761276
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 )
12851285{
12861286 result -> merge = 0 ;
12871287 result -> clean = 1 ;
@@ -1366,56 +1366,6 @@ static int merge_file_1(struct merge_options *o,
13661366 return 0 ;
13671367}
13681368
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-
14191369static int handle_rename_via_dir (struct merge_options * o ,
14201370 struct diff_filepair * pair ,
14211371 const char * rename_branch ,
@@ -1659,11 +1609,8 @@ static int handle_rename_rename_1to2(struct merge_options *o,
16591609 struct merge_file_info mfi ;
16601610 struct diff_filespec other ;
16611611 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 ))
16671614 return -1 ;
16681615
16691616 /*
@@ -1729,14 +1676,10 @@ static int handle_rename_rename_2to1(struct merge_options *o,
17291676
17301677 path_side_1_desc = xstrfmt ("%s (was %s)" , path , a -> path );
17311678 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 ))
17401683 return -1 ;
17411684 free (path_side_1_desc );
17421685 free (path_side_2_desc );
@@ -2766,12 +2709,23 @@ static int process_renames(struct merge_options *o,
27662709 ren1_dst , branch2 );
27672710 if (o -> call_depth ) {
27682711 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 )) {
27752729 clean_merge = -1 ;
27762730 goto cleanup_and_return ;
27772731 }
@@ -3021,13 +2975,13 @@ static int handle_modify_delete(struct merge_options *o,
30212975 _ ("modify" ), _ ("modified" ));
30222976}
30232977
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 )
30312985{
30322986 const char * reason = _ ("content" );
30332987 const char * path1 = NULL , * path2 = NULL ;
@@ -3059,14 +3013,16 @@ static int merge_content(struct merge_options *o,
30593013 path2 = (rename_conflict_info -> pair2 ||
30603014 o -> branch2 == rename_conflict_info -> branch1 ) ?
30613015 pair1 -> two -> path : pair1 -> one -> path ;
3016+ one .path = pair1 -> one -> path ;
3017+ a .path = (char * )path1 ;
3018+ b .path = (char * )path2 ;
30623019
30633020 if (dir_in_way (path , !o -> call_depth ,
30643021 S_ISGITLINK (pair1 -> two -> mode )))
30653022 df_conflict_remains = 1 ;
30663023 }
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 ))
30703026 return -1 ;
30713027
30723028 /*
@@ -3157,9 +3113,9 @@ static int handle_rename_normal(struct merge_options *o,
31573113 struct rename_conflict_info * ci )
31583114{
31593115 /* 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 );
31633119}
31643120
31653121/* Per entry merge function */
@@ -3283,9 +3239,11 @@ static int process_entry(struct merge_options *o,
32833239 /* Case C: Added in both (check for same permissions) and */
32843240 /* case D: Modified in both, but differently. */
32853241 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 );
32893247 } else if (!o_oid && !a_oid && !b_oid ) {
32903248 /*
32913249 * this entry was deleted altogether. a_mode == 0 means
0 commit comments