Skip to contentSkip to conversation

merge-recursive: option to disable renames

PATCH Superseded Felipe Gonçalves Assis 1 participant 3 messages Jun 15, 2016 Documentation

v4 of 5 Superseded Latest is v5 →

lore
Share & tools
lore
#0 lore raw

v4 cover merge-recursive: option to disable renames

Incorporate documentation input from Eric Sunshine. Fix missing signoff.

The first part is unchanged.

No tests are included for now. This work is being done in parallel and should be properly included in future proposals.

Felipe Gonçalves Assis (2):
merge-recursive: option to disable renames
merge-recursive: more consistent interface

 Documentation/merge-strategies.txt | 12 ++++++++++--
 merge-recursive.c                  | 12 +++++++++++-
 merge-recursive.h                  |  1 +
 3 files changed, 22 insertions(+), 3 deletions(-)
Signature · 1 line
2.7.1.289.ga0c045c
#1 lore raw

PATCH v4 1/2 merge-recursive: option to disable renames

The recursive strategy turns on rename detection by default. Add a strategy option to disable rename detection even for exact renames.

---
 Documentation/merge-strategies.txt | 6 ++++++
 merge-recursive.c                  | 7 +++++++
 merge-recursive.h                  | 1 +
 3 files changed, 14 insertions(+)
Documentation/merge-strategies.txt +6 -0
index 7bbd19b..1a5e197 100644
@@ -81,8 +81,14 @@ no-renormalize;;
 	Disables the `renormalize` option.  This overrides the
 	`merge.renormalize` configuration variable.
 
+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.
+	Re-enables rename detection if disabled by a preceding
+	`no-renames`.
 	See also linkgit:git-diff[1] `-M`.
 
 subtree[=<path>];;
merge-recursive.c +7 -0
index 8eabde2..6dd0a11 100644
@@ -482,6 +482,9 @@ 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);
@@ -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 = 1;
 	merge_recursive_config(o);
 	if (getenv("GIT_MERGE_VERBOSITY"))
 		o->verbosity =
@@ -2088,9 +2092,12 @@ 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, "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;
+		o->detect_rename = 1;
 	}
 	else
 		return -1;
merge-recursive.h +1 -0
index 9e090a3..52f0201 100644
@@ -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;
Signature · 1 line
2.7.1.289.ga0c045c
#2 lore raw

PATCH v4 2/2 merge-recursive: more consistent interface

In reply to Felipe Gonçalves Assis

Add strategy option find-renames, following git-diff interface. This makes the option rename-threshold redundant.

---
 Documentation/merge-strategies.txt | 10 ++++++----
 merge-recursive.c                  |  5 ++++-
 2 files changed, 10 insertions(+), 5 deletions(-)
Documentation/merge-strategies.txt +6 -4
index 1a5e197..ff359b6 100644
@@ -85,11 +85,13 @@ no-renames;;
 	Turn off rename detection.
 	See also linkgit:git-diff[1] `--no-renames`.
 
+find-renames[=<n>];;
+	Turn on rename detection, optionally setting the the similarity
+	threshold. This is the default.
+	See also linkgit:git-diff[1] `--find-renames`.
+
 rename-threshold=<n>;;
-	Controls the similarity threshold used for rename detection.
-	Re-enables rename detection if disabled by a preceding
-	`no-renames`.
-	See also linkgit:git-diff[1] `-M`.
+	Deprecated synonym for `find-renames=<n>`.
 
 subtree[=<path>];;
 	This option is a more advanced form of 'subtree' strategy, where
merge-recursive.c +4 -1
index 6dd0a11..700febd 100644
@@ -2094,7 +2094,10 @@ int parse_merge_opt(struct merge_options *o, const char *s)
 		o->renormalize = 0;
 	else if (!strcmp(s, "no-renames"))
 		o->detect_rename = 0;
-	else if (skip_prefix(s, "rename-threshold=", &arg)) {
+	else if (!strcmp(s, "find-renames"))
+		o->detect_rename = 1;
+	else if (skip_prefix(s, "find-renames=", &arg) ||
+	         skip_prefix(s, "rename-threshold=", &arg)) {
 		if ((o->rename_score = parse_rename_score(&arg)) == -1 || *arg != 0)
 			return -1;
 		o->detect_rename = 1;
Signature · 1 line
2.7.1.289.ga0c045c