diff: add synonyms for -M, -C, -B
Add new long-form options --detect-renames[=<n>], --detect-copies[=<n>], and --break-rewrites[=[<n>][/<m>]] as synonyms for the -M, -C, and -B options (respectively). Signed-off-by: Kevin Ballard <kevin@sb.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Kevin Ballard committed
Sep 27, 2010 at 16:58 UTC
37ab5156ae31ec81e3489406f23be6936a2a370c
2 files changed
+25
-3
Documentation/diff-options.txt
+3
@@ -207,9 +207,11 @@ endif::git-format-patch[]
207
digits can be specified with `--abbrev=<n>`.
208
209
-B::
210
+--break-rewrites[=[<n>][/<m>]]::
211
Break complete rewrite changes into pairs of delete and create.
212
213
-M::
214
+--detect-renames[=<n>]::
215
ifndef::git-log[]
216
Detect renames.
217
endif::git-log[]
@@ -220,6 +222,7 @@ ifdef::git-log[]
222
endif::git-log[]
223
224
-C::
225
+--detect-copies[=<n>]::
226
Detect copies as well as renames. See also `--find-copies-harder`.
227
228
ifndef::git-format-patch[]
diff.c
+22
-3
@@ -3059,16 +3059,19 @@ int diff_opt_parse(struct diff_options *options, const char **av, int ac)
3059
}
3060
3061
/* renames options */
3062
- else if (!prefixcmp(arg, "-B")) {
3062
+ else if (!prefixcmp(arg, "-B") || !prefixcmp(arg, "--break-rewrites=") ||
3063
+ !strcmp(arg, "--break-rewrites")) {
3064
if ((options->break_opt = diff_scoreopt_parse(arg)) == -1)
3065
return -1;
3066
}
3066
- else if (!prefixcmp(arg, "-M")) {
3067
+ else if (!prefixcmp(arg, "-M") || !prefixcmp(arg, "--detect-renames=") ||
3068
+ !strcmp(arg, "--detect-renames")) {
3069
if ((options->rename_score = diff_scoreopt_parse(arg)) == -1)
3070
return -1;
3071
options->detect_rename = DIFF_DETECT_RENAME;
3072
}
3071
- else if (!prefixcmp(arg, "-C")) {
3073
+ else if (!prefixcmp(arg, "-C") || !prefixcmp(arg, "--detect-copies=") ||
3074
+ !strcmp(arg, "--detect-copies")) {
3075
if (options->detect_rename == DIFF_DETECT_COPY)
3076
DIFF_OPT_SET(options, FIND_COPIES_HARDER);
3077
if ((options->rename_score = diff_scoreopt_parse(arg)) == -1)
@@ -3262,6 +3265,22 @@ static int diff_scoreopt_parse(const char *opt)
3265
if (*opt++ != '-')
3266
return -1;
3267
cmd = *opt++;
3268
+ if (cmd == '-') {
3269
+ /* convert the long-form arguments into short-form versions */
3270
+ if (!prefixcmp(opt, "break-rewrites")) {
3271
+ opt += strlen("break-rewrites");
3272
+ if (*opt == 0 || *opt++ == '=')
3273
+ cmd = 'B';
3274
+ } else if (!prefixcmp(opt, "detect-copies")) {
3275
+ opt += strlen("detect-copies");
3276
+ if (*opt == 0 || *opt++ == '=')
3277
+ cmd = 'C';
3278
+ } else if (!prefixcmp(opt, "detect-renames")) {
3279
+ opt += strlen("detect-renames");
3280
+ if (*opt == 0 || *opt++ == '=')
3281
+ cmd = 'M';
3282
+ }
3283
+ }
3284
if (cmd != 'M' && cmd != 'C' && cmd != 'B')
3285
return -1; /* that is not a -M, -C nor -B option */
3286