Skip to content

Commit 3992ff0

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 9cfee25 commit 3992ff0

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
@@ -1339,8 +1339,6 @@ static struct string_list *get_renames(struct merge_options *o,
13391339
struct diff_options opts;
13401340

13411341
renames = xcalloc(1, sizeof(struct string_list));
1342-
if (!o->detect_rename)
1343-
return renames;
13441342

13451343
diff_setup(&opts);
13461344
opts.flags.recursive = 1;
@@ -1658,6 +1656,12 @@ static int handle_renames(struct merge_options *o,
16581656
struct string_list *entries,
16591657
struct rename_info *ri)
16601658
{
1659+
ri->head_renames = NULL;
1660+
ri->merge_renames = NULL;
1661+
1662+
if (!o->detect_rename)
1663+
return 1;
1664+
16611665
ri->head_renames = get_renames(o, head, common, head, merge, entries);
16621666
ri->merge_renames = get_renames(o, merge, common, head, merge, entries);
16631667
return process_renames(o, ri->head_renames, ri->merge_renames);
@@ -1668,6 +1672,9 @@ static void cleanup_rename(struct string_list *rename)
16681672
const struct rename *re;
16691673
int i;
16701674

1675+
if (rename == NULL)
1676+
return;
1677+
16711678
for (i = 0; i < rename->nr; i++) {
16721679
re = rename->items[i].util;
16731680
diff_free_filepair(re->pair);

0 commit comments

Comments
 (0)