Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@xxxxxxxxx> --- merge-recursive.c | 49 +++++++++++++++++++++++++++++++++---------------- 1 file changed, 33 insertions(+), 16 deletions(-) diff --git a/merge-recursive.c b/merge-recursive.c index 680937c..1cc6360 100644 --- a/merge-recursive.c +++ b/merge-recursive.c @@ -1018,9 +1018,27 @@ static void handle_change_delete(struct merge_options *o, const unsigned char *o_sha, int o_mode, const unsigned char *a_sha, int a_mode, const unsigned char *b_sha, int b_mode, - const char *change, const char *change_past) + const char *change) { char *renamed = NULL; + int idx; + + const char *msg[] = { + "CONFLICT (rename/delete): %s deleted in %s and renamed in %s. Version %s of %s left in tree.", + "CONFLICT (modify/delete): %s deleted in %s and modified in %s. Version %s of %s left in tree.", + }; + const char *renamed_msg[] = { + "CONFLICT (rename/delete): %s deleted in %s and renamed in %s. Version %s of %s left in tree at %s.", + "CONFLICT (modify/delete): %s deleted in %s and modified in %s. Version %s of %s left in tree at %s.", + }; + + if (!strcmp(change, "rename")) + idx = 0; + else if (!strcmp(change, "modify")) + idx = 1; + else + die("BUG: unsupport action %s", change); + if (dir_in_way(path, !o->call_depth)) { renamed = unique_path(o, path, a_sha ? o->branch1 : o->branch2); } @@ -1034,22 +1052,21 @@ static void handle_change_delete(struct merge_options *o, remove_file_from_cache(path); update_file(o, 0, o_sha, o_mode, renamed ? renamed : path); } else if (!a_sha) { - output(o, 1, "CONFLICT (%s/delete): %s deleted in %s " - "and %s in %s. Version %s of %s left in tree%s%s.", - change, path, o->branch1, - change_past, o->branch2, o->branch2, path, - NULL == renamed ? "" : " at ", - NULL == renamed ? "" : renamed); + if (renamed) + output(o, 1, renamed_msg[idx], path, o->branch1, + o->branch2, o->branch2, path, renamed); + else + output(o, 1, msg[idx], path, o->branch1, + o->branch2, o->branch2, path); update_file(o, 0, b_sha, b_mode, renamed ? renamed : path); } else { - output(o, 1, "CONFLICT (%s/delete): %s deleted in %s " - "and %s in %s. Version %s of %s left in tree%s%s.", - change, path, o->branch2, - change_past, o->branch1, o->branch1, path, - NULL == renamed ? "" : " at ", - NULL == renamed ? "" : renamed); - if (renamed) + if (renamed) { + output(o, 1, renamed_msg[idx], path, o->branch2, + o->branch1, o->branch1, path, renamed); update_file(o, 0, a_sha, a_mode, renamed); + } else + output(o, 1, msg[idx], path, o->branch2, + o->branch1, o->branch1, path); /* * No need to call update_file() on path when !renamed, since * that would needlessly touch path. We could call @@ -1085,7 +1102,7 @@ static void conflict_rename_delete(struct merge_options *o, orig->sha1, orig->mode, a_sha, a_mode, b_sha, b_mode, - "rename", "renamed"); + "rename"); if (o->call_depth) { remove_file_from_cache(dest->path); @@ -1568,7 +1585,7 @@ static void handle_modify_delete(struct merge_options *o, o_sha, o_mode, a_sha, a_mode, b_sha, b_mode, - "modify", "modified"); + "modify"); } static int merge_content(struct merge_options *o, -- 1.7.10.2.549.g9354186 -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html