@@ -1061,16 +1061,20 @@ static int merge_file_one(struct merge_options *o,
1061
1061
}
1062
1062
1063
1063
static int handle_change_delete (struct merge_options * o ,
1064
- const char * path ,
1064
+ const char * path , const char * old_path ,
1065
1065
const struct object_id * o_oid , int o_mode ,
1066
- const struct object_id * a_oid , int a_mode ,
1067
- const struct object_id * b_oid , int b_mode ,
1066
+ const struct object_id * changed_oid ,
1067
+ int changed_mode ,
1068
+ const char * change_branch ,
1069
+ const char * delete_branch ,
1068
1070
const char * change , const char * change_past )
1069
1071
{
1070
- char * renamed = NULL ;
1072
+ char * alt_path = NULL ;
1073
+ const char * update_path = path ;
1071
1074
int ret = 0 ;
1075
+
1072
1076
if (dir_in_way (path , !o -> call_depth , 0 )) {
1073
- renamed = unique_path (o , path , a_oid ? o -> branch1 : o -> branch2 );
1077
+ update_path = alt_path = unique_path (o , path , change_branch );
1074
1078
}
1075
1079
1076
1080
if (o -> call_depth ) {
@@ -1081,72 +1085,61 @@ static int handle_change_delete(struct merge_options *o,
1081
1085
*/
1082
1086
ret = remove_file_from_cache (path );
1083
1087
if (!ret )
1084
- ret = update_file (o , 0 , o_oid , o_mode ,
1085
- renamed ? renamed : path );
1086
- } else if (!a_oid ) {
1087
- if (!renamed ) {
1088
- output (o , 1 , _ ("CONFLICT (%s/delete): %s deleted in %s "
1089
- "and %s in %s. Version %s of %s left in tree." ),
1090
- change , path , o -> branch1 , change_past ,
1091
- o -> branch2 , o -> branch2 , path );
1092
- ret = update_file (o , 0 , b_oid , b_mode , path );
1093
- } else {
1094
- output (o , 1 , _ ("CONFLICT (%s/delete): %s deleted in %s "
1095
- "and %s in %s. Version %s of %s left in tree at %s." ),
1096
- change , path , o -> branch1 , change_past ,
1097
- o -> branch2 , o -> branch2 , path , renamed );
1098
- ret = update_file (o , 0 , b_oid , b_mode , renamed );
1099
- }
1088
+ ret = update_file (o , 0 , o_oid , o_mode , update_path );
1100
1089
} else {
1101
- if (!renamed ) {
1102
- output (o , 1 , _ ("CONFLICT (%s/delete): %s deleted in %s "
1103
- "and %s in %s. Version %s of %s left in tree." ),
1104
- change , path , o -> branch2 , change_past ,
1105
- o -> branch1 , o -> branch1 , path );
1090
+ if (!alt_path ) {
1091
+ if (!old_path ) {
1092
+ output (o , 1 , _ ("CONFLICT (%s/delete): %s deleted in %s "
1093
+ "and %s in %s. Version %s of %s left in tree." ),
1094
+ change , path , delete_branch , change_past ,
1095
+ change_branch , change_branch , path );
1096
+ } else {
1097
+ output (o , 1 , _ ("CONFLICT (%s/delete): %s deleted in %s "
1098
+ "and %s to %s in %s. Version %s of %s left in tree." ),
1099
+ change , old_path , delete_branch , change_past , path ,
1100
+ change_branch , change_branch , path );
1101
+ }
1106
1102
} else {
1107
- output (o , 1 , _ ("CONFLICT (%s/delete): %s deleted in %s "
1108
- "and %s in %s. Version %s of %s left in tree at %s." ),
1109
- change , path , o -> branch2 , change_past ,
1110
- o -> branch1 , o -> branch1 , path , renamed );
1111
- ret = update_file (o , 0 , a_oid , a_mode , renamed );
1103
+ if (!old_path ) {
1104
+ output (o , 1 , _ ("CONFLICT (%s/delete): %s deleted in %s "
1105
+ "and %s in %s. Version %s of %s left in tree at %s." ),
1106
+ change , path , delete_branch , change_past ,
1107
+ change_branch , change_branch , path , alt_path );
1108
+ } else {
1109
+ output (o , 1 , _ ("CONFLICT (%s/delete): %s deleted in %s "
1110
+ "and %s to %s in %s. Version %s of %s left in tree at %s." ),
1111
+ change , old_path , delete_branch , change_past , path ,
1112
+ change_branch , change_branch , path , alt_path );
1113
+ }
1112
1114
}
1113
1115
/*
1114
- * No need to call update_file() on path when !renamed, since
1115
- * that would needlessly touch path. We could call
1116
- * update_file_flags() with update_cache=0 and update_wd=0,
1117
- * but that's a no-op.
1116
+ * No need to call update_file() on path when change_branch ==
1117
+ * o->branch1 && !alt_path, since that would needlessly touch
1118
+ * path. We could call update_file_flags() with update_cache=0
1119
+ * and update_wd=0, but that's a no-op.
1118
1120
*/
1121
+ if (change_branch != o -> branch1 || alt_path )
1122
+ ret = update_file (o , 0 , changed_oid , changed_mode , update_path );
1119
1123
}
1120
- free (renamed );
1124
+ free (alt_path );
1121
1125
1122
1126
return ret ;
1123
1127
}
1124
1128
1125
1129
static int conflict_rename_delete (struct merge_options * o ,
1126
1130
struct diff_filepair * pair ,
1127
1131
const char * rename_branch ,
1128
- const char * other_branch )
1132
+ const char * delete_branch )
1129
1133
{
1130
1134
const struct diff_filespec * orig = pair -> one ;
1131
1135
const struct diff_filespec * dest = pair -> two ;
1132
- const struct object_id * a_oid = NULL ;
1133
- const struct object_id * b_oid = NULL ;
1134
- int a_mode = 0 ;
1135
- int b_mode = 0 ;
1136
-
1137
- if (rename_branch == o -> branch1 ) {
1138
- a_oid = & dest -> oid ;
1139
- a_mode = dest -> mode ;
1140
- } else {
1141
- b_oid = & dest -> oid ;
1142
- b_mode = dest -> mode ;
1143
- }
1144
1136
1145
1137
if (handle_change_delete (o ,
1146
1138
o -> call_depth ? orig -> path : dest -> path ,
1139
+ o -> call_depth ? NULL : orig -> path ,
1147
1140
& orig -> oid , orig -> mode ,
1148
- a_oid , a_mode ,
1149
- b_oid , b_mode ,
1141
+ & dest -> oid , dest -> mode ,
1142
+ rename_branch , delete_branch ,
1150
1143
_ ("rename" ), _ ("renamed" )))
1151
1144
return -1 ;
1152
1145
@@ -1662,11 +1655,27 @@ static int handle_modify_delete(struct merge_options *o,
1662
1655
struct object_id * a_oid , int a_mode ,
1663
1656
struct object_id * b_oid , int b_mode )
1664
1657
{
1658
+ const char * modify_branch , * delete_branch ;
1659
+ struct object_id * changed_oid ;
1660
+ int changed_mode ;
1661
+
1662
+ if (a_oid ) {
1663
+ modify_branch = o -> branch1 ;
1664
+ delete_branch = o -> branch2 ;
1665
+ changed_oid = a_oid ;
1666
+ changed_mode = a_mode ;
1667
+ } else {
1668
+ modify_branch = o -> branch2 ;
1669
+ delete_branch = o -> branch1 ;
1670
+ changed_oid = b_oid ;
1671
+ changed_mode = b_mode ;
1672
+ }
1673
+
1665
1674
return handle_change_delete (o ,
1666
- path ,
1675
+ path , NULL ,
1667
1676
o_oid , o_mode ,
1668
- a_oid , a_mode ,
1669
- b_oid , b_mode ,
1677
+ changed_oid , changed_mode ,
1678
+ modify_branch , delete_branch ,
1670
1679
_ ("modify" ), _ ("modified" ));
1671
1680
}
1672
1681
0 commit comments