Skip to content

Commit e7f04a3

Browse files
newrengitster
authored andcommitted
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 <[email protected]> Signed-off-by: Elijah Newren <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 9622f8a commit e7f04a3

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

merge-recursive.c

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1329,8 +1329,6 @@ static struct string_list *get_renames(struct merge_options *o,
13291329
struct diff_options opts;
13301330

13311331
renames = xcalloc(1, sizeof(struct string_list));
1332-
if (!o->detect_rename)
1333-
return renames;
13341332

13351333
diff_setup(&opts);
13361334
opts.flags.recursive = 1;
@@ -1648,6 +1646,12 @@ static int handle_renames(struct merge_options *o,
16481646
struct string_list *entries,
16491647
struct rename_info *ri)
16501648
{
1649+
ri->head_renames = NULL;
1650+
ri->merge_renames = NULL;
1651+
1652+
if (!o->detect_rename)
1653+
return 1;
1654+
16511655
ri->head_renames = get_renames(o, head, common, head, merge, entries);
16521656
ri->merge_renames = get_renames(o, merge, common, head, merge, entries);
16531657
return process_renames(o, ri->head_renames, ri->merge_renames);
@@ -1658,6 +1662,9 @@ static void cleanup_rename(struct string_list *rename)
16581662
const struct rename *re;
16591663
int i;
16601664

1665+
if (rename == NULL)
1666+
return;
1667+
16611668
for (i = 0; i < rename->nr; i++) {
16621669
re = rename->items[i].util;
16631670
diff_free_filepair(re->pair);

0 commit comments

Comments
 (0)