Thread (1 message) 1 message, 1 author, 2016-06-15

Re: [PATCH] merge-recursive: option to disable renames

From: Junio C Hamano <hidden>
Date: 2016-06-15 23:08:16
Subsystem: the rest · Maintainer: Linus Torvalds

Possibly related (same subject, not in this thread)

Junio C Hamano [off-list ref] writes:
"Felipe Gonçalves Assis"  [off-list ref] writes:
quoted
+no-renames;;
+	Turn off rename detection.
+	See also linkgit:git-diff[1] `--no-renames`.
Even though by default for merge-recursive the rename detection is
on, if we are adding an option to control this aspect of the
behaviour from the command line, it should follow the usual pattern,
i.e.

 (1) the code to parse options would allow an earlier "--no-renames"
     on the command line to be overridden with a later "--renames"; and

 (2) the description in the documentation would be headed by
     "--[no-]renames", describes which one is the default, etc.
quoted
diff --git a/merge-recursive.c b/merge-recursive.c
index 8eabde2..ca67805 100644
--- a/merge-recursive.c
+++ b/merge-recursive.c
@@ -1839,9 +1839,16 @@ int merge_trees(struct merge_options *o,
 
 		entries = get_unmerged();
 		record_df_conflict_files(o, entries);
-		re_head  = get_renames(o, head, common, head, merge, entries);
-		re_merge = get_renames(o, merge, common, head, merge, entries);
-		clean = process_renames(o, re_head, re_merge);
+		if (o->detect_rename) {
+			re_head  = get_renames(o, head, common, head, merge, entries);
+			re_merge = get_renames(o, merge, common, head, merge, entries);
+			clean = process_renames(o, re_head, re_merge);
+		}
+		else {
+			re_head  = xcalloc(1, sizeof(struct string_list));
+			re_merge = xcalloc(1, sizeof(struct string_list));
+			clean = 1;
+		}
Yup, this is much nicer than butchering diffcore-rename.c for no
good reason ;-).
Thinking about this a bit deeper, you are already passing o to
get_renames, so I think the right place to decide "Oh, I can just
return an empty list" is inside that function.  That is, the meat of
the change in this patch should be just these three lines instead, I
think.  You'd of course need to have addition of that new field,
option parsing, and documentation update in addition to that.

Thanks.


 merge-recursive.c | 3 +++
 1 file changed, 3 insertions(+)
diff --git a/merge-recursive.c b/merge-recursive.c
index 8eabde2..69fb947 100644
--- a/merge-recursive.c
+++ b/merge-recursive.c
@@ -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);
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help