* [PATCH v2] merge-recursive: option to disable renames
@ 2016-02-16 23:26 Felipe Gonçalves Assis
2016-02-17 0:20 ` Junio C Hamano
0 siblings, 1 reply; 2+ messages in thread
From: Felipe Gonçalves Assis @ 2016-02-16 23:26 UTC (permalink / raw)
To: git; +Cc: Johannes.Schindelin, gitster, Felipe Gonçalves Assis
The recursive strategy turns on rename detection by default. Add a
strategy option to disable rename detection even for exact renames.
Signed-off-by: Felipe Gonçalves Assis <felipegassis@gmail.com>
---
Following Hamano's review, this patch includes a strategy option "renames" and
simplifies the implementation.
Also note merge-recursive.c:492, where I forward detect_rename from the merge
options to the diff options, instead of hardcoding it to DIFF_DETECT_RENAME,
which could cause surprises in the future.
Documentation/merge-strategies.txt | 9 +++++++++
merge-recursive.c | 10 +++++++++-
merge-recursive.h | 1 +
3 files changed, 19 insertions(+), 1 deletion(-)
diff --git a/Documentation/merge-strategies.txt b/Documentation/merge-strategies.txt
index 7bbd19b..f794d23 100644
--- a/Documentation/merge-strategies.txt
+++ b/Documentation/merge-strategies.txt
@@ -81,6 +81,15 @@ no-renormalize;;
Disables the `renormalize` option. This overrides the
`merge.renormalize` configuration variable.
+renames;;
+ Turn on rename detection.
+ This is the default.
+ See also linkgit:git-diff[1] `-M`.
+
+no-renames;;
+ Turn off rename detection.
+ See also linkgit:git-diff[1] `--no-renames`.
+
rename-threshold=<n>;;
Controls the similarity threshold used for rename detection.
See also linkgit:git-diff[1] `-M`.
diff --git a/merge-recursive.c b/merge-recursive.c
index 8eabde2..2f9c40a 100644
--- a/merge-recursive.c
+++ b/merge-recursive.c
@@ -482,10 +482,13 @@ static struct string_list *get_renames(struct merge_options *o,
struct diff_options opts;
renames = xcalloc(1, sizeof(struct string_list));
+ if (!o->detect_rename)
+ return renames;
+
diff_setup(&opts);
DIFF_OPT_SET(&opts, RECURSIVE);
DIFF_OPT_CLR(&opts, RENAME_EMPTY);
- opts.detect_rename = DIFF_DETECT_RENAME;
+ opts.detect_rename = o->detect_rename;
opts.rename_limit = o->merge_rename_limit >= 0 ? o->merge_rename_limit :
o->diff_rename_limit >= 0 ? o->diff_rename_limit :
1000;
@@ -2039,6 +2042,7 @@ void init_merge_options(struct merge_options *o)
o->diff_rename_limit = -1;
o->merge_rename_limit = -1;
o->renormalize = 0;
+ o->detect_rename = DIFF_DETECT_RENAME;
merge_recursive_config(o);
if (getenv("GIT_MERGE_VERBOSITY"))
o->verbosity =
@@ -2088,6 +2092,10 @@ int parse_merge_opt(struct merge_options *o, const char *s)
o->renormalize = 1;
else if (!strcmp(s, "no-renormalize"))
o->renormalize = 0;
+ else if (!strcmp(s, "renames"))
+ o->detect_rename = DIFF_DETECT_RENAME;
+ else if (!strcmp(s, "no-renames"))
+ o->detect_rename = 0;
else if (skip_prefix(s, "rename-threshold=", &arg)) {
if ((o->rename_score = parse_rename_score(&arg)) == -1 || *arg != 0)
return -1;
diff --git a/merge-recursive.h b/merge-recursive.h
index 9e090a3..52f0201 100644
--- a/merge-recursive.h
+++ b/merge-recursive.h
@@ -17,6 +17,7 @@ struct merge_options {
unsigned renormalize : 1;
long xdl_opts;
int verbosity;
+ int detect_rename;
int diff_rename_limit;
int merge_rename_limit;
int rename_score;
--
2.7.1.288.g6752e66
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH v2] merge-recursive: option to disable renames
2016-02-16 23:26 [PATCH v2] merge-recursive: option to disable renames Felipe Gonçalves Assis
@ 2016-02-17 0:20 ` Junio C Hamano
0 siblings, 0 replies; 2+ messages in thread
From: Junio C Hamano @ 2016-02-17 0:20 UTC (permalink / raw)
To: Felipe Gonçalves Assis
Cc: git, Johannes.Schindelin, Felipe Gonçalves Assis
"Felipe Gonçalves Assis" <felipeg.assis@gmail.com> writes:
> @@ -482,10 +482,13 @@ static struct string_list *get_renames(struct merge_options *o,
> struct diff_options opts;
>
> renames = xcalloc(1, sizeof(struct string_list));
> + if (!o->detect_rename)
> + return renames;
> +
> diff_setup(&opts);
> DIFF_OPT_SET(&opts, RECURSIVE);
> DIFF_OPT_CLR(&opts, RENAME_EMPTY);
> - opts.detect_rename = DIFF_DETECT_RENAME;
> + opts.detect_rename = o->detect_rename;
> opts.rename_limit = o->merge_rename_limit >= 0 ? o->merge_rename_limit :
> o->diff_rename_limit >= 0 ? o->diff_rename_limit :
> 1000;
I do not think you want the latter change. Also o->detect_rename
should be just a simple boolean and it is better not to link its
value with DIFF_ANYTHING symbol.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2016-02-17 0:20 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-02-16 23:26 [PATCH v2] merge-recursive: option to disable renames Felipe Gonçalves Assis
2016-02-17 0:20 ` Junio C Hamano
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).