diffcore-rename: fall back to -C when -C -C busts the rename limit
When there are too many paths in the project, the number of rename source candidates "git diff -C -C" finds will exceed the rename detection limit, and no inexact rename detection is performed. We however could fall back to "git diff -C" if the number of modified paths is sufficiently small. Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
26
diff.c
26
diff.c
@ -3956,6 +3956,28 @@ static int is_summary_empty(const struct diff_queue_struct *q)
|
||||
return 1;
|
||||
}
|
||||
|
||||
static const char rename_limit_warning[] =
|
||||
"inexact rename detection was skipped due to too many files.";
|
||||
|
||||
static const char degrade_cc_to_c_warning[] =
|
||||
"only found copies from modified paths due to too many files.";
|
||||
|
||||
static const char rename_limit_advice[] =
|
||||
"you may want to set your %s variable to at least "
|
||||
"%d and retry the command.";
|
||||
|
||||
void diff_warn_rename_limit(const char *varname, int needed, int degraded_cc)
|
||||
{
|
||||
if (degraded_cc)
|
||||
warning(degrade_cc_to_c_warning);
|
||||
else if (needed)
|
||||
warning(rename_limit_warning);
|
||||
else
|
||||
return;
|
||||
if (0 < needed && needed < 32767)
|
||||
warning(rename_limit_advice, varname, needed);
|
||||
}
|
||||
|
||||
void diff_flush(struct diff_options *options)
|
||||
{
|
||||
struct diff_queue_struct *q = &diff_queued_diff;
|
||||
@ -4237,6 +4259,10 @@ void diffcore_std(struct diff_options *options)
|
||||
int diff_result_code(struct diff_options *opt, int status)
|
||||
{
|
||||
int result = 0;
|
||||
|
||||
diff_warn_rename_limit("diff.renamelimit",
|
||||
opt->needed_rename_limit,
|
||||
opt->degraded_cc_to_c);
|
||||
if (!DIFF_OPT_TST(opt, EXIT_WITH_STATUS) &&
|
||||
!(opt->output_format & DIFF_FORMAT_CHECKDIFF))
|
||||
return status;
|
||||
|
Reference in New Issue
Block a user