{"thread":{"id":"41428","subject":"[PATCH v2] merge-recursive: option to disable renames","startedAt":"2016-02-16T23:26:15Z","lastAt":"2016-02-17T00:20:06Z","messageCount":2,"participants":["Felipe Gonçalves Assis","Junio C Hamano"],"isPatch":true,"patchVersion":2,"patchTotal":null},"messages":[{"id":"278412","messageId":"1455665175-8665-1-git-send-email-felipegassis@gmail.com","threadId":"41428","inReplyTo":null,"subject":"[PATCH v2] merge-recursive: option to disable renames","fromName":"Felipe Gonçalves Assis","fromEmail":"felipeg.assis@gmail.com","sentAt":"2016-02-16T23:26:15Z","receivedAt":"2016-02-16T23:26:15Z","isPatch":true,"sender":{"key":"felipeg.assis@gmail.com","avatar":null},"body":"The recursive strategy turns on rename detection by default. Add a\nstrategy option to disable rename detection even for exact renames.\n\nSigned-off-by: Felipe Gonçalves Assis <felipegassis@gmail.com>\n---\n\nFollowing Hamano's review, this patch includes a strategy option \"renames\" and\nsimplifies the implementation.\n\nAlso note merge-recursive.c:492, where I forward detect_rename from the merge\noptions to the diff options, instead of hardcoding it to DIFF_DETECT_RENAME,\nwhich could cause surprises in the future.\n\n Documentation/merge-strategies.txt |  9 +++++++++\n merge-recursive.c                  | 10 +++++++++-\n merge-recursive.h                  |  1 +\n 3 files changed, 19 insertions(+), 1 deletion(-)\n\ndiff --git a/Documentation/merge-strategies.txt b/Documentation/merge-strategies.txt\nindex 7bbd19b..f794d23 100644\n--- a/Documentation/merge-strategies.txt\n+++ b/Documentation/merge-strategies.txt\n@@ -81,6 +81,15 @@ no-renormalize;;\n \tDisables the `renormalize` option.  This overrides the\n \t`merge.renormalize` configuration variable.\n \n+renames;;\n+\tTurn on rename detection.\n+\tThis is the default.\n+\tSee also linkgit:git-diff[1] `-M`.\n+\n+no-renames;;\n+\tTurn off rename detection.\n+\tSee also linkgit:git-diff[1] `--no-renames`.\n+\n rename-threshold=<n>;;\n \tControls the similarity threshold used for rename detection.\n \tSee also linkgit:git-diff[1] `-M`.\ndiff --git a/merge-recursive.c b/merge-recursive.c\nindex 8eabde2..2f9c40a 100644\n--- a/merge-recursive.c\n+++ b/merge-recursive.c\n@@ -482,10 +482,13 @@ static struct string_list *get_renames(struct merge_options *o,\n \tstruct diff_options opts;\n \n \trenames = xcalloc(1, sizeof(struct string_list));\n+\tif (!o->detect_rename)\n+\t\treturn renames;\n+\n \tdiff_setup(&opts);\n \tDIFF_OPT_SET(&opts, RECURSIVE);\n \tDIFF_OPT_CLR(&opts, RENAME_EMPTY);\n-\topts.detect_rename = DIFF_DETECT_RENAME;\n+\topts.detect_rename = o->detect_rename;\n \topts.rename_limit = o->merge_rename_limit >= 0 ? o->merge_rename_limit :\n \t\t\t    o->diff_rename_limit >= 0 ? o->diff_rename_limit :\n \t\t\t    1000;\n@@ -2039,6 +2042,7 @@ void init_merge_options(struct merge_options *o)\n \to->diff_rename_limit = -1;\n \to->merge_rename_limit = -1;\n \to->renormalize = 0;\n+\to->detect_rename = DIFF_DETECT_RENAME;\n \tmerge_recursive_config(o);\n \tif (getenv(\"GIT_MERGE_VERBOSITY\"))\n \t\to->verbosity =\n@@ -2088,6 +2092,10 @@ int parse_merge_opt(struct merge_options *o, const char *s)\n \t\to->renormalize = 1;\n \telse if (!strcmp(s, \"no-renormalize\"))\n \t\to->renormalize = 0;\n+\telse if (!strcmp(s, \"renames\"))\n+\t\to->detect_rename = DIFF_DETECT_RENAME;\n+\telse if (!strcmp(s, \"no-renames\"))\n+\t\to->detect_rename = 0;\n \telse if (skip_prefix(s, \"rename-threshold=\", &arg)) {\n \t\tif ((o->rename_score = parse_rename_score(&arg)) == -1 || *arg != 0)\n \t\t\treturn -1;\ndiff --git a/merge-recursive.h b/merge-recursive.h\nindex 9e090a3..52f0201 100644\n--- a/merge-recursive.h\n+++ b/merge-recursive.h\n@@ -17,6 +17,7 @@ struct merge_options {\n \tunsigned renormalize : 1;\n \tlong xdl_opts;\n \tint verbosity;\n+\tint detect_rename;\n \tint diff_rename_limit;\n \tint merge_rename_limit;\n \tint rename_score;\n-- \n2.7.1.288.g6752e66\n"},{"id":"278420","messageId":"xmqq7fi4kx1l.fsf@gitster.mtv.corp.google.com","threadId":"41428","inReplyTo":"1455665175-8665-1-git-send-email-felipegassis@gmail.com","subject":"Re: [PATCH v2] merge-recursive: option to disable renames","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2016-02-17T00:20:06Z","receivedAt":"2016-02-17T00:20:06Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"Felipe Gonçalves Assis\"  <felipeg.assis@gmail.com> writes:\n\n> @@ -482,10 +482,13 @@ static struct string_list *get_renames(struct merge_options *o,\n>  \tstruct diff_options opts;\n>  \n>  \trenames = xcalloc(1, sizeof(struct string_list));\n> +\tif (!o->detect_rename)\n> +\t\treturn renames;\n> +\n>  \tdiff_setup(&opts);\n>  \tDIFF_OPT_SET(&opts, RECURSIVE);\n>  \tDIFF_OPT_CLR(&opts, RENAME_EMPTY);\n> -\topts.detect_rename = DIFF_DETECT_RENAME;\n> +\topts.detect_rename = o->detect_rename;\n>  \topts.rename_limit = o->merge_rename_limit >= 0 ? o->merge_rename_limit :\n>  \t\t\t    o->diff_rename_limit >= 0 ? o->diff_rename_limit :\n>  \t\t\t    1000;\n\nI do not think you want the latter change.  Also o->detect_rename\nshould be just a simple boolean and it is better not to link its\nvalue with DIFF_ANYTHING symbol.\n"}]}