Andrew's git
/
gitweb.git
/ diff
summary
|
log
|
commit
| diff |
tree
commit
grep
author
committer
pickaxe
?
re
diff-parseopt: convert --word-diff-regex
author
Nguyễn Thái Ngọc Duy
<pclouds@gmail.com>
Tue, 5 Mar 2019 12:30:19 +0000
(19:30 +0700)
committer
Junio C Hamano
<gitster@pobox.com>
Wed, 6 Mar 2019 23:02:22 +0000
(08:02 +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:
e9fb39b
)
diff --git
a/diff.c
b/diff.c
index 14c057f3df491225fd874b76b22d9b5d7641a35b..634981723b87551ef47560d5e67f7ade120d5d84 100644
(file)
--- a/
diff.c
+++ b/
diff.c
@@
-5092,6
+5092,18
@@
static int diff_opt_word_diff(const struct option *opt,
return 0;
}
return 0;
}
+static int diff_opt_word_diff_regex(const struct option *opt,
+ const char *arg, int unset)
+{
+ struct diff_options *options = opt->value;
+
+ BUG_ON_OPT_NEG(unset);
+ if (options->word_diff == DIFF_WORDS_NONE)
+ options->word_diff = DIFF_WORDS_PLAIN;
+ options->word_regex = arg;
+ return 0;
+}
+
static void prep_parse_options(struct diff_options *options)
{
struct option parseopts[] = {
static void prep_parse_options(struct diff_options *options)
{
struct option parseopts[] = {
@@
-5257,6
+5269,9
@@
static void prep_parse_options(struct diff_options *options)
OPT_CALLBACK_F(0, "word-diff", options, N_("<mode>"),
N_("show word diff, using <mode> to delimit changed words"),
PARSE_OPT_NONEG | PARSE_OPT_OPTARG, diff_opt_word_diff),
OPT_CALLBACK_F(0, "word-diff", options, N_("<mode>"),
N_("show word diff, using <mode> to delimit changed words"),
PARSE_OPT_NONEG | PARSE_OPT_OPTARG, diff_opt_word_diff),
+ OPT_CALLBACK_F(0, "word-diff-regex", options, N_("<regex>"),
+ N_("use <regex> to decide what a word is"),
+ PARSE_OPT_NONEG, diff_opt_word_diff_regex),
OPT_GROUP(N_("Diff other options")),
OPT_CALLBACK_F(0, "relative", options, N_("<prefix>"),
OPT_GROUP(N_("Diff other options")),
OPT_CALLBACK_F(0, "relative", options, N_("<prefix>"),
@@
-5320,12
+5335,6
@@
int diff_opt_parse(struct diff_options *options,
options->use_color = 1;
options->word_diff = DIFF_WORDS_COLOR;
}
options->use_color = 1;
options->word_diff = DIFF_WORDS_COLOR;
}
- else if ((argcount = parse_long_opt("word-diff-regex", av, &optarg))) {
- if (options->word_diff == DIFF_WORDS_NONE)
- options->word_diff = DIFF_WORDS_PLAIN;
- options->word_regex = optarg;
- return argcount;
- }
else if (!strcmp(arg, "--exit-code"))
options->flags.exit_with_status = 1;
else if (!strcmp(arg, "--quiet"))
else if (!strcmp(arg, "--exit-code"))
options->flags.exit_with_status = 1;
else if (!strcmp(arg, "--quiet"))