Subject: [PATCH 18/30] merge-recursive: Make !o->detect_rename codepath more obvious

From: Elijah Newren <[email-masked]>
Date: Fri, 10 Nov 2017 11:05:38 -0800

Previously, if !o->detect_rename then get_renames() would return an
empty string_list, and then process_renames() would have nothing to
iterate over.  It seems more straightforward to simply avoid calling
either function in that case.

Signed-off-by: Elijah Newren <[email-masked]>
---
 merge-recursive.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/merge-recursive.c b/merge-recursive.c
index 7a3402e50c..f40c70990c 100644
--- a/merge-recursive.c
+++ b/merge-recursive.c
@@ -1332,8 +1332,6 @@ 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);
@@ -1652,6 +1650,10 @@ static struct rename_info *handle_renames(struct merge_options *o,
 {
 	struct rename_info *rei = xcalloc(1, sizeof(struct rename_info));
 
+	*clean = 1;
+	if (!o->detect_rename)
+		return NULL;
+
 	rei->head_renames  = get_renames(o, head, common, head, merge, entries);
 	rei->merge_renames = get_renames(o, merge, common, head, merge, entries);
 	*clean = process_renames(o, rei->head_renames, rei->merge_renames);
@@ -1664,6 +1666,9 @@ static void cleanup_renames(struct rename_info *re_info)
 	const struct rename *re;
 	int i;
 
+	if (!re_info)
+		return;
+
 	for (i = 0; i < re_info->head_renames->nr; i++) {
 		re = re_info->head_renames->items[i].util;
 		diff_free_filepair(re->pair);
-- 
2.15.0.5.g9567be9905