Skip to content

Commit f39d05c

Browse files
newrengitster
authored andcommitted
merge-ort: implement detect_regular_renames()
Based heavily on merge-recursive's get_diffpairs() function, and also includes the necessary paired call to diff_warn_rename_limit() so that users will be warned if merge.renameLimit is not sufficiently large for rename detection to run. Signed-off-by: Elijah Newren <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent e1a124e commit f39d05c

File tree

1 file changed

+31
-1
lines changed

1 file changed

+31
-1
lines changed

merge-ort.c

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -661,7 +661,33 @@ static void detect_regular_renames(struct merge_options *opt,
661661
struct tree *side,
662662
unsigned side_index)
663663
{
664-
die("Not yet implemented.");
664+
struct diff_options diff_opts;
665+
struct rename_info *renames = &opt->priv->renames;
666+
667+
repo_diff_setup(opt->repo, &diff_opts);
668+
diff_opts.flags.recursive = 1;
669+
diff_opts.flags.rename_empty = 0;
670+
diff_opts.detect_rename = DIFF_DETECT_RENAME;
671+
diff_opts.rename_limit = opt->rename_limit;
672+
if (opt->rename_limit <= 0)
673+
diff_opts.rename_limit = 1000;
674+
diff_opts.rename_score = opt->rename_score;
675+
diff_opts.show_rename_progress = opt->show_rename_progress;
676+
diff_opts.output_format = DIFF_FORMAT_NO_OUTPUT;
677+
diff_setup_done(&diff_opts);
678+
diff_tree_oid(&merge_base->object.oid, &side->object.oid, "",
679+
&diff_opts);
680+
diffcore_std(&diff_opts);
681+
682+
if (diff_opts.needed_rename_limit > renames->needed_limit)
683+
renames->needed_limit = diff_opts.needed_rename_limit;
684+
685+
renames->pairs[side_index] = diff_queued_diff;
686+
687+
diff_opts.output_format = DIFF_FORMAT_NO_OUTPUT;
688+
diff_queued_diff.nr = 0;
689+
diff_queued_diff.queue = NULL;
690+
diff_flush(&diff_opts);
665691
}
666692

667693
/*
@@ -1406,6 +1432,10 @@ void merge_switch_to_result(struct merge_options *opt,
14061432
printf("%s", sb->buf);
14071433
}
14081434
string_list_clear(&olist, 0);
1435+
1436+
/* Also include needed rename limit adjustment now */
1437+
diff_warn_rename_limit("merge.renamelimit",
1438+
opti->renames.needed_limit, 0);
14091439
}
14101440

14111441
merge_finalize(opt, result);

0 commit comments

Comments
 (0)