@matheusbsbs / matheus-bagliano / commits / 5e3ce663b0
Fork 0

merge-recursive: Move delete/modify handling into dedicated function

This move is in preparation for the function being called from multiple places in order to handle D/F conflicts. Signed-off-by: Elijah Newren <newren@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Elijah Newren committed Sep 20, 2010 at 02:28 UTC 5e3ce663b03bf14443ef8b4c60b407664f97040b
1 file changed +22 -13
merge-recursive.c
+22 -13
@@ -1118,6 +1118,26 @@ error_return:
1118 return ret;
1119 }
1120
1121 +static void handle_delete_modify(struct merge_options *o,
1122 + const char *path,
1123 + unsigned char *a_sha, int a_mode,
1124 + unsigned char *b_sha, int b_mode)
1125 +{
1126 + if (!a_sha) {
1127 + output(o, 1, "CONFLICT (delete/modify): %s deleted in %s "
1128 + "and modified in %s. Version %s of %s left in tree.",
1129 + path, o->branch1,
1130 + o->branch2, o->branch2, path);
1131 + update_file(o, 0, b_sha, b_mode, path);
1132 + } else {
1133 + output(o, 1, "CONFLICT (delete/modify): %s deleted in %s "
1134 + "and modified in %s. Version %s of %s left in tree.",
1135 + path, o->branch2,
1136 + o->branch1, o->branch1, path);
1137 + update_file(o, 0, a_sha, a_mode, path);
1138 + }
1139 +}
1140 +
1141 /* Per entry merge function */
1142 static int process_entry(struct merge_options *o,
1143 const char *path, struct stage_data *entry)
@@ -1150,19 +1170,8 @@ static int process_entry(struct merge_options *o,
1170 } else {
1171 /* Deleted in one and changed in the other */
1172 clean_merge = 0;
1153 - if (!a_sha) {
1154 - output(o, 1, "CONFLICT (delete/modify): %s deleted in %s "
1155 - "and modified in %s. Version %s of %s left in tree.",
1156 - path, o->branch1,
1157 - o->branch2, o->branch2, path);
1158 - update_file(o, 0, b_sha, b_mode, path);
1159 - } else {
1160 - output(o, 1, "CONFLICT (delete/modify): %s deleted in %s "
1161 - "and modified in %s. Version %s of %s left in tree.",
1162 - path, o->branch2,
1163 - o->branch1, o->branch1, path);
1164 - update_file(o, 0, a_sha, a_mode, path);
1165 - }
1173 + handle_delete_modify(o, path,
1174 + a_sha, a_mode, b_sha, b_mode);
1175 }
1176
1177 } else if ((!o_sha && a_sha && !b_sha) ||