Skip to content

Commit ca6c097

Browse files
dschogitster
authored andcommitted
Teach diff to imply --find-copies-harder upon -C -C
Earlier, a second "-C" on the command line had no effect. But "--find-copies-harder" is so long to type, let's make doubled -C enable that option. It is in line with how "git blame" handles such doubled options to mean "work harder". Signed-off-by: Johannes Schindelin <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent d52fd42 commit ca6c097

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

Documentation/diff-options.txt

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@
8686
Detect renames.
8787

8888
-C::
89-
Detect copies as well as renames.
89+
Detect copies as well as renames. See also `--find-copies-harder`.
9090

9191
--diff-filter=[ACDMRTUXB*]::
9292
Select only files that are Added (`A`), Copied (`C`),
@@ -100,12 +100,13 @@
100100
that matches other criteria, nothing is selected.
101101

102102
--find-copies-harder::
103-
For performance reasons, by default, -C option finds copies only
103+
For performance reasons, by default, `-C` option finds copies only
104104
if the original file of the copy was modified in the same
105105
changeset. This flag makes the command
106106
inspect unmodified files as candidates for the source of
107107
copy. This is a very expensive operation for large
108-
projects, so use it with caution.
108+
projects, so use it with caution. Giving more than one
109+
`-C` option has the same effect.
109110

110111
-l<num>::
111112
-M and -C options require O(n^2) processing time where n

diff.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2201,6 +2201,8 @@ int diff_opt_parse(struct diff_options *options, const char **av, int ac)
22012201
options->detect_rename = DIFF_DETECT_RENAME;
22022202
}
22032203
else if (!prefixcmp(arg, "-C")) {
2204+
if (options->detect_rename == DIFF_DETECT_COPY)
2205+
options->find_copies_harder = 1;
22042206
if ((options->rename_score =
22052207
diff_scoreopt_parse(arg)) == -1)
22062208
return -1;

0 commit comments

Comments
 (0)