Skip to content

Commit 268055b

Browse files
committed
Merge branch 'en/rename-limits-doc'
Documentation on "git diff -l<n>" and diff.renameLimit have been updated, and the defaults for these limits have been raised. * en/rename-limits-doc: rename: bump limit defaults yet again diffcore-rename: treat a rename_limit of 0 as unlimited doc: clarify documentation for rename/copy limits diff: correct warning message when renameLimit exceeded
2 parents 546adc4 + 94b82d5 commit 268055b

File tree

7 files changed

+26
-17
lines changed

7 files changed

+26
-17
lines changed

Documentation/config/diff.txt

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -118,9 +118,10 @@ diff.orderFile::
118118
relative to the top of the working tree.
119119

120120
diff.renameLimit::
121-
The number of files to consider when performing the copy/rename
122-
detection; equivalent to the 'git diff' option `-l`. This setting
123-
has no effect if rename detection is turned off.
121+
The number of files to consider in the exhaustive portion of
122+
copy/rename detection; equivalent to the 'git diff' option
123+
`-l`. If not set, the default value is currently 1000. This
124+
setting has no effect if rename detection is turned off.
124125

125126
diff.renames::
126127
Whether and how Git detects renames. If set to "false",

Documentation/config/merge.txt

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,12 @@ merge.verifySignatures::
3333
include::fmt-merge-msg.txt[]
3434

3535
merge.renameLimit::
36-
The number of files to consider when performing rename detection
37-
during a merge; if not specified, defaults to the value of
38-
diff.renameLimit. This setting has no effect if rename detection
39-
is turned off.
36+
The number of files to consider in the exhaustive portion of
37+
rename detection during a merge. If not specified, defaults
38+
to the value of diff.renameLimit. If neither
39+
merge.renameLimit nor diff.renameLimit are specified,
40+
currently defaults to 7000. This setting has no effect if
41+
rename detection is turned off.
4042

4143
merge.renames::
4244
Whether Git detects renames. If set to "false", rename detection

Documentation/diff-options.txt

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -588,11 +588,17 @@ When used together with `-B`, omit also the preimage in the deletion part
588588
of a delete/create pair.
589589

590590
-l<num>::
591-
The `-M` and `-C` options require O(n^2) processing time where n
592-
is the number of potential rename/copy targets. This
593-
option prevents rename/copy detection from running if
594-
the number of rename/copy targets exceeds the specified
595-
number.
591+
The `-M` and `-C` options involve some preliminary steps that
592+
can detect subsets of renames/copies cheaply, followed by an
593+
exhaustive fallback portion that compares all remaining
594+
unpaired destinations to all relevant sources. (For renames,
595+
only remaining unpaired sources are relevant; for copies, all
596+
original sources are relevant.) For N sources and
597+
destinations, this exhaustive check is O(N^2). This option
598+
prevents the exhaustive portion of rename/copy detection from
599+
running if the number of source/destination files involved
600+
exceeds the specified number. Defaults to diff.renameLimit.
601+
Note that a value of 0 is treated as unlimited.
596602

597603
ifndef::git-format-patch[]
598604
--diff-filter=[(A|C|D|M|R|T|U|X|B)...[*]]::

diff.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535

3636
static int diff_detect_rename_default;
3737
static int diff_indent_heuristic = 1;
38-
static int diff_rename_limit_default = 400;
38+
static int diff_rename_limit_default = 1000;
3939
static int diff_suppress_blank_empty;
4040
static int diff_use_color_default = -1;
4141
static int diff_color_moved_default;
@@ -6295,7 +6295,7 @@ static int is_summary_empty(const struct diff_queue_struct *q)
62956295
}
62966296

62976297
static const char rename_limit_warning[] =
6298-
N_("inexact rename detection was skipped due to too many files.");
6298+
N_("exhaustive rename detection was skipped due to too many files.");
62996299

63006300
static const char degrade_cc_to_c_warning[] =
63016301
N_("only found copies from modified paths due to too many files.");

diffcore-rename.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1091,7 +1091,7 @@ static int too_many_rename_candidates(int num_destinations, int num_sources,
10911091
* memory for the matrix anyway.
10921092
*/
10931093
if (rename_limit <= 0)
1094-
rename_limit = 32767;
1094+
return 0; /* treat as unlimited */
10951095
if (st_mult(num_destinations, num_sources)
10961096
<= st_mult(rename_limit, rename_limit))
10971097
return 0;

merge-ort.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2563,7 +2563,7 @@ static void detect_regular_renames(struct merge_options *opt,
25632563
diff_opts.detect_rename = DIFF_DETECT_RENAME;
25642564
diff_opts.rename_limit = opt->rename_limit;
25652565
if (opt->rename_limit <= 0)
2566-
diff_opts.rename_limit = 1000;
2566+
diff_opts.rename_limit = 7000;
25672567
diff_opts.rename_score = opt->rename_score;
25682568
diff_opts.show_rename_progress = opt->show_rename_progress;
25692569
diff_opts.output_format = DIFF_FORMAT_NO_OUTPUT;

merge-recursive.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1880,7 +1880,7 @@ static struct diff_queue_struct *get_diffpairs(struct merge_options *opt,
18801880
*/
18811881
if (opts.detect_rename > DIFF_DETECT_RENAME)
18821882
opts.detect_rename = DIFF_DETECT_RENAME;
1883-
opts.rename_limit = (opt->rename_limit >= 0) ? opt->rename_limit : 1000;
1883+
opts.rename_limit = (opt->rename_limit >= 0) ? opt->rename_limit : 7000;
18841884
opts.rename_score = opt->rename_score;
18851885
opts.show_rename_progress = opt->show_rename_progress;
18861886
opts.output_format = DIFF_FORMAT_NO_OUTPUT;

0 commit comments

Comments
 (0)