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 <Johannes.Schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Johannes Schindelin committed
Jun 11, 2007 at 21:12 UTC
ca6c097089a38d447de0190ea61e9746a40a170c
2 files changed
+6
-3
Documentation/diff-options.txt
+4
-3
@@ -86,7 +86,7 @@
86
Detect renames.
87
88
-C::
89
- Detect copies as well as renames.
89
+ Detect copies as well as renames. See also `--find-copies-harder`.
90
91
--diff-filter=[ACDMRTUXB*]::
92
Select only files that are Added (`A`), Copied (`C`),
@@ -100,12 +100,13 @@
100
that matches other criteria, nothing is selected.
101
102
--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
104
if the original file of the copy was modified in the same
105
changeset. This flag makes the command
106
inspect unmodified files as candidates for the source of
107
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.
110
111
-l<num>::
112
-M and -C options require O(n^2) processing time where n
diff.c
+2
@@ -2201,6 +2201,8 @@ int diff_opt_parse(struct diff_options *options, const char **av, int ac)
2201
options->detect_rename = DIFF_DETECT_RENAME;
2202
}
2203
else if (!prefixcmp(arg, "-C")) {
2204
+ if (options->detect_rename == DIFF_DETECT_COPY)
2205
+ options->find_copies_harder = 1;
2206
if ((options->rename_score =
2207
diff_scoreopt_parse(arg)) == -1)
2208
return -1;