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
Feb 14, 2018 at 10:51 UTC
e7f04a3aafe3fa9bc911e3a71e03e9e7cc8b18ba
1 file changed
+9
-2
merge-recursive.c
+9
-2
@@ -1329,8 +1329,6 @@ static struct string_list *get_renames(struct merge_options *o,
1329
struct diff_options opts;
1330
1331
renames = xcalloc(1, sizeof(struct string_list));
1332
- if (!o->detect_rename)
1333
- return renames;
1332
1333
diff_setup(&opts);
1334
opts.flags.recursive = 1;
@@ -1648,6 +1646,12 @@ static int handle_renames(struct merge_options *o,
1646
struct string_list *entries,
1647
struct rename_info *ri)
1648
{
1649
+ ri->head_renames = NULL;
1650
+ ri->merge_renames = NULL;
1651
+
1652
+ if (!o->detect_rename)
1653
+ return 1;
1654
+
1655
ri->head_renames = get_renames(o, head, common, head, merge, entries);
1656
ri->merge_renames = get_renames(o, merge, common, head, merge, entries);
1657
return process_renames(o, ri->head_renames, ri->merge_renames);
@@ -1658,6 +1662,9 @@ static void cleanup_rename(struct string_list *rename)
1662
const struct rename *re;
1663
int i;
1664
1665
+ if (rename == NULL)
1666
+ return;
1667
+
1668
for (i = 0; i < rename->nr; i++) {
1669
re = rename->items[i].util;
1670
diff_free_filepair(re->pair);