@@ -5056,6 +5056,28 @@ static int diff_opt_patience(const struct option *opt,
return 0;
}
+static int diff_opt_pickaxe_regex(const struct option *opt,
+ const char *arg, int unset)
+{
+ struct diff_options *options = opt->value;
+
+ BUG_ON_OPT_NEG(unset);
+ options->pickaxe = arg;
+ options->pickaxe_opts |= DIFF_PICKAXE_KIND_G;
+ return 0;
+}
+
+static int diff_opt_pickaxe_string(const struct option *opt,
+ const char *arg, int unset)
+{
+ struct diff_options *options = opt->value;
+
+ BUG_ON_OPT_NEG(unset);
+ options->pickaxe = arg;
+ options->pickaxe_opts |= DIFF_PICKAXE_KIND_S;
+ return 0;
+}
+
static int diff_opt_relative(const struct option *opt,
const char *arg, int unset)
{
@@ -5363,6 +5385,12 @@ static void prep_parse_options(struct diff_options *options)
OPT_SET_INT_F(0, "ita-visible-in-index", &options->ita_invisible_in_index,
N_("treat 'git add -N' entries as real in the index"),
0, PARSE_OPT_NONEG),
+ OPT_CALLBACK_F('S', NULL, options, N_("<string>"),
+ N_("look for differences that change the number of occurrences of the specified string"),
+ 0, diff_opt_pickaxe_string),
+ OPT_CALLBACK_F('G', NULL, options, N_("<regex>"),
+ N_("look for differences that change the number of occurrences of the specified regex"),
+ 0, diff_opt_pickaxe_regex),
{ OPTION_CALLBACK, 0, "output", options, N_("<file>"),
N_("Output to a specific file"),
PARSE_OPT_NONEG, NULL, 0, diff_opt_output },
@@ -5415,15 +5443,6 @@ int diff_opt_parse(struct diff_options *options,
}
/* misc options */
- else if ((argcount = short_opt('S', av, &optarg))) {
- options->pickaxe = optarg;
- options->pickaxe_opts |= DIFF_PICKAXE_KIND_S;
- return argcount;
- } else if ((argcount = short_opt('G', av, &optarg))) {
- options->pickaxe = optarg;
- options->pickaxe_opts |= DIFF_PICKAXE_KIND_G;
- return argcount;
- }
else if (!strcmp(arg, "--pickaxe-all"))
options->pickaxe_opts |= DIFF_PICKAXE_ALL;
else if (!strcmp(arg, "--pickaxe-regex"))
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> --- diff.c | 37 ++++++++++++++++++++++++++++--------- 1 file changed, 28 insertions(+), 9 deletions(-)