|
|
|
@ -4909,6 +4909,22 @@ static int diff_opt_dirstat(const struct option *opt,
@@ -4909,6 +4909,22 @@ static int diff_opt_dirstat(const struct option *opt,
|
|
|
|
|
return 0; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
static int diff_opt_find_renames(const struct option *opt, |
|
|
|
|
const char *arg, int unset) |
|
|
|
|
{ |
|
|
|
|
struct diff_options *options = opt->value; |
|
|
|
|
|
|
|
|
|
BUG_ON_OPT_NEG(unset); |
|
|
|
|
if (!arg) |
|
|
|
|
arg = ""; |
|
|
|
|
options->rename_score = parse_rename_score(&arg); |
|
|
|
|
if (*arg != 0) |
|
|
|
|
return error(_("invalid argument to %s"), opt->long_name); |
|
|
|
|
|
|
|
|
|
options->detect_rename = DIFF_DETECT_RENAME; |
|
|
|
|
return 0; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
static enum parse_opt_result diff_opt_output(struct parse_opt_ctx_t *ctx, |
|
|
|
|
const struct option *opt, |
|
|
|
|
const char *arg, int unset) |
|
|
|
@ -5040,6 +5056,10 @@ static void prep_parse_options(struct diff_options *options)
@@ -5040,6 +5056,10 @@ static void prep_parse_options(struct diff_options *options)
|
|
|
|
|
N_("break complete rewrite changes into pairs of delete and create"), |
|
|
|
|
PARSE_OPT_NONEG | PARSE_OPT_OPTARG, |
|
|
|
|
diff_opt_break_rewrites), |
|
|
|
|
OPT_CALLBACK_F('M', "find-renames", options, N_("<n>"), |
|
|
|
|
N_("detect renames"), |
|
|
|
|
PARSE_OPT_NONEG | PARSE_OPT_OPTARG, |
|
|
|
|
diff_opt_find_renames), |
|
|
|
|
|
|
|
|
|
OPT_GROUP(N_("Diff other options")), |
|
|
|
|
{ OPTION_CALLBACK, 0, "output", options, N_("<file>"), |
|
|
|
@ -5074,13 +5094,7 @@ int diff_opt_parse(struct diff_options *options,
@@ -5074,13 +5094,7 @@ int diff_opt_parse(struct diff_options *options,
|
|
|
|
|
return ac; |
|
|
|
|
|
|
|
|
|
/* renames options */ |
|
|
|
|
if (starts_with(arg, "-M") || |
|
|
|
|
skip_to_optional_arg(arg, "--find-renames", NULL)) { |
|
|
|
|
if ((options->rename_score = diff_scoreopt_parse(arg)) == -1) |
|
|
|
|
return error("invalid argument to -M: %s", arg+2); |
|
|
|
|
options->detect_rename = DIFF_DETECT_RENAME; |
|
|
|
|
} |
|
|
|
|
else if (!strcmp(arg, "-D") || !strcmp(arg, "--irreversible-delete")) { |
|
|
|
|
if (!strcmp(arg, "-D") || !strcmp(arg, "--irreversible-delete")) { |
|
|
|
|
options->irreversible_delete = 1; |
|
|
|
|
} |
|
|
|
|
else if (starts_with(arg, "-C") || |
|
|
|
@ -5363,13 +5377,10 @@ static int diff_scoreopt_parse(const char *opt)
@@ -5363,13 +5377,10 @@ static int diff_scoreopt_parse(const char *opt)
|
|
|
|
|
if (skip_prefix(opt, "find-copies", &opt)) { |
|
|
|
|
if (*opt == 0 || *opt++ == '=') |
|
|
|
|
cmd = 'C'; |
|
|
|
|
} else if (skip_prefix(opt, "find-renames", &opt)) { |
|
|
|
|
if (*opt == 0 || *opt++ == '=') |
|
|
|
|
cmd = 'M'; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
if (cmd != 'M' && cmd != 'C') |
|
|
|
|
return -1; /* that is not a -M, or -C option */ |
|
|
|
|
if (cmd != 'C') |
|
|
|
|
return -1; /* that is not a -M option */ |
|
|
|
|
|
|
|
|
|
opt1 = parse_rename_score(&opt); |
|
|
|
|
if (*opt != 0) |
|
|
|
|