For one-time amateurs, --rename-file could be used to specify what path should be renamed to what path between heads and the merge base, when they hit big merge conflicts because diff fails to recognize renames correctly. Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@xxxxxxxxx> --- builtin/merge.c | 9 +++++++++ merge-recursive.c | 1 + merge-recursive.h | 1 + 3 files changed, 11 insertions(+) diff --git a/builtin/merge.c b/builtin/merge.c index 15bf95b..95a6c26 100644 --- a/builtin/merge.c +++ b/builtin/merge.c @@ -67,6 +67,8 @@ static int abort_current_merge; static int show_progress = -1; static int default_to_upstream = 1; static const char *sign_commit; +static const char *rename_file; +static struct strbuf manual_renames = STRBUF_INIT; static struct strategy all_strategy[] = { { "recursive", DEFAULT_TWOHEAD | NO_TRIVIAL }, @@ -225,6 +227,7 @@ static struct option builtin_merge_options[] = { { OPTION_STRING, 'S', "gpg-sign", &sign_commit, N_("key-id"), N_("GPG sign commit"), PARSE_OPT_OPTARG, NULL, (intptr_t) "" }, OPT_BOOL(0, "overwrite-ignore", &overwrite_ignore, N_("update ignored files (default)")), + OPT_FILENAME(0, "rename-file", &rename_file, N_("--rename-file to diff")), OPT_END() }; @@ -664,6 +667,8 @@ static int try_merge_strategy(const char *strategy, struct commit_list *common, o.renormalize = option_renormalize; o.show_rename_progress = show_progress == -1 ? isatty(2) : show_progress; + if (manual_renames.len) + o.manual_renames = manual_renames.buf; for (x = 0; x < xopts_nr; x++) if (parse_merge_opt(&o, xopts[x])) @@ -1255,6 +1260,10 @@ int cmd_merge(int argc, const char **argv, const char *prefix) usage_with_options(builtin_merge_usage, builtin_merge_options); + if (rename_file && + strbuf_read_file(&manual_renames, rename_file, 0) == -1) + die(_("unable to read %s"), rename_file); + if (!head_commit) { struct commit *remote_head; /* diff --git a/merge-recursive.c b/merge-recursive.c index 8eabde2..ec7e044 100644 --- a/merge-recursive.c +++ b/merge-recursive.c @@ -492,6 +492,7 @@ static struct string_list *get_renames(struct merge_options *o, opts.rename_score = o->rename_score; opts.show_rename_progress = o->show_rename_progress; opts.output_format = DIFF_FORMAT_NO_OUTPUT; + opts.manual_renames = o->manual_renames; diff_setup_done(&opts); diff_tree_sha1(o_tree->object.oid.hash, tree->object.oid.hash, "", &opts); diffcore_std(&opts); diff --git a/merge-recursive.h b/merge-recursive.h index 9e090a3..898b169 100644 --- a/merge-recursive.h +++ b/merge-recursive.h @@ -27,6 +27,7 @@ struct merge_options { struct string_list current_file_set; struct string_list current_directory_set; struct string_list df_conflict_file_set; + const char *manual_renames; }; /* merge_trees() but with recursive ancestor consolidation */ -- 2.7.0.125.g9eec362 -- 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