merge-recursive: make !o->detect_rename codepath more obvious
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. Reviewed-by: Stefan Beller <sbeller@google.com> Signed-off-by: Elijah Newren <newren@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Elijah Newren committed
Apr 19, 2018 at 10:58 UTC
3992ff0c4caf925373b61aa17ab507207bf7e645
1 file changed
+9
-2
merge-recursive.c
+9
-2
@@ -1339,8 +1339,6 @@ static struct string_list *get_renames(struct merge_options *o,
1339
struct diff_options opts;
1340
1341
renames = xcalloc(1, sizeof(struct string_list));
1342
- if (!o->detect_rename)
1343
- return renames;
1342
1343
diff_setup(&opts);
1344
opts.flags.recursive = 1;
@@ -1658,6 +1656,12 @@ static int handle_renames(struct merge_options *o,
1656
struct string_list *entries,
1657
struct rename_info *ri)
1658
{
1659
+ ri->head_renames = NULL;
1660
+ ri->merge_renames = NULL;
1661
+
1662
+ if (!o->detect_rename)
1663
+ return 1;
1664
+
1665
ri->head_renames = get_renames(o, head, common, head, merge, entries);
1666
ri->merge_renames = get_renames(o, merge, common, head, merge, entries);
1667
return process_renames(o, ri->head_renames, ri->merge_renames);
@@ -1668,6 +1672,9 @@ static void cleanup_rename(struct string_list *rename)
1672
const struct rename *re;
1673
int i;
1674
1675
+ if (rename == NULL)
1676
+ return;
1677
+
1678
for (i = 0; i < rename->nr; i++) {
1679
re = rename->items[i].util;
1680
diff_free_filepair(re->pair);