@matheusbsbs / matheus-bagliano / commits / 84a08a47b9
Fork 0

handle_delete_modify(): Check whether D/F conflicts are still present

If all the paths below some directory involved in a D/F conflict were not removed during the rest of the merge, then the contents of the file whose path conflicted needs to be recorded in file with an alternative filename. 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:29 UTC 84a08a47b9559e76df96645c536845f31ba4dc7b
2 files changed +17 -10
merge-recursive.c
+16 -9
@@ -1164,25 +1164,29 @@ error_return:
1164
1165 static void handle_delete_modify(struct merge_options *o,
1166 const char *path,
1167 + const char *new_path,
1168 unsigned char *a_sha, int a_mode,
1169 unsigned char *b_sha, int b_mode)
1170 {
1171 if (!a_sha) {
1172 output(o, 1, "CONFLICT (delete/modify): %s deleted in %s "
1172 - "and modified in %s. Version %s of %s left in tree.",
1173 + "and modified in %s. Version %s of %s left in tree%s%s.",
1174 path, o->branch1,
1174 - o->branch2, o->branch2, path);
1175 - update_file(o, 0, b_sha, b_mode, path);
1175 + o->branch2, o->branch2, path,
1176 + path == new_path ? "" : " at ",
1177 + path == new_path ? "" : new_path);
1178 + update_file(o, 0, b_sha, b_mode, new_path);
1179 } else {
1180 output(o, 1, "CONFLICT (delete/modify): %s deleted in %s "
1178 - "and modified in %s. Version %s of %s left in tree.",
1181 + "and modified in %s. Version %s of %s left in tree%s%s.",
1182 path, o->branch2,
1180 - o->branch1, o->branch1, path);
1181 - update_file(o, 0, a_sha, a_mode, path);
1183 + o->branch1, o->branch1, path,
1184 + path == new_path ? "" : " at ",
1185 + path == new_path ? "" : new_path);
1186 + update_file(o, 0, a_sha, a_mode, new_path);
1187 }
1188 }
1189
1185 -
1190 static int merge_content(struct merge_options *o,
1191 const char *path,
1192 unsigned char *o_sha, int o_mode,
@@ -1281,7 +1285,7 @@ static int process_entry(struct merge_options *o,
1285 } else {
1286 /* Deleted in one and changed in the other */
1287 clean_merge = 0;
1284 - handle_delete_modify(o, path,
1288 + handle_delete_modify(o, path, path,
1289 a_sha, a_mode, b_sha, b_mode);
1290 }
1291
@@ -1398,8 +1402,11 @@ static int process_df_entry(struct merge_options *o,
1402 }
1403 } else if (o_sha && (!a_sha || !b_sha)) {
1404 /* Modify/delete; deleted side may have put a directory in the way */
1405 + const char *new_path = path;
1406 + if (lstat(path, &st) == 0 && S_ISDIR(st.st_mode))
1407 + new_path = unique_path(o, path, a_sha ? o->branch1 : o->branch2);
1408 clean_merge = 0;
1402 - handle_delete_modify(o, path,
1409 + handle_delete_modify(o, path, new_path,
1410 a_sha, a_mode, b_sha, b_mode);
1411 } else if (!o_sha && !!a_sha != !!b_sha) {
1412 /* directory -> (directory, file) */
t/t6020-merge-df.sh
+1 -1
@@ -71,7 +71,7 @@ test_expect_success 'setup modify/delete + directory/file conflict' '
71 git commit -m deleted
72 '
73
74 -test_expect_failure 'modify/delete + directory/file conflict' '
74 +test_expect_success 'modify/delete + directory/file conflict' '
75 git checkout delete^0 &&
76 test_must_fail git merge modify &&
77