Andrew's git
/
gitweb.git
/ diff
summary
|
log
|
commit
| diff |
tree
commit
grep
author
committer
pickaxe
?
re
diff-parseopt: convert -S|-G
author
Nguyễn Thái Ngọc Duy
<pclouds@gmail.com>
Sun, 24 Mar 2019 08:19:59 +0000
(15:19 +0700)
committer
Junio C Hamano
<gitster@pobox.com>
Sun, 24 Mar 2019 13:21:22 +0000
(22:21 +0900)
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
diff.c
patch
|
blob
|
history
raw
|
patch
|
inline
| side by side (parent:
bffee74
)
diff --git
a/diff.c
b/diff.c
index 6b19c9749970f2c03902953570da2aa7fa85b086..8f01fbc2c167510b4b6c031d43149acb4c7334df 100644
(file)
--- a/
diff.c
+++ b/
diff.c
@@
-5056,6
+5056,28
@@
static int diff_opt_patience(const struct option *opt,
return 0;
}
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)
{
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_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 },
{ 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 */
}
/* 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"))
else if (!strcmp(arg, "--pickaxe-all"))
options->pickaxe_opts |= DIFF_PICKAXE_ALL;
else if (!strcmp(arg, "--pickaxe-regex"))