diff-parseopt: convert --diff-filter
While at it, mark one more string for translation Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Nguyễn Thái Ngọc Duy committed
Mar 24, 2019 at 15:20 UTC
d2d3f27300967e76e0c9f3a916e7e236ff95f1aa
1 file changed
+9
-9
diff.c
+9
-9
@@ -4736,10 +4736,13 @@ static unsigned filter_bit_tst(char status, const struct diff_options *opt)
4736
return opt->filter & filter_bit[(int) status];
4737
}
4738
4739
-static int parse_diff_filter_opt(const char *optarg, struct diff_options *opt)
4739
+static int diff_opt_diff_filter(const struct option *option,
4740
+ const char *optarg, int unset)
4741
{
4742
+ struct diff_options *opt = option->value;
4743
int i, optch;
4744
4745
+ BUG_ON_OPT_NEG(unset);
4746
prepare_filter_bits();
4747
4748
/*
@@ -4770,7 +4773,8 @@ static int parse_diff_filter_opt(const char *optarg, struct diff_options *opt)
4773
4774
bit = (0 <= optch && optch <= 'Z') ? filter_bit[optch] : 0;
4775
if (!bit)
4773
- return optarg[i];
4776
+ return error(_("unknown change class '%c' in --diff-filter=%s"),
4777
+ optarg[i], optarg);
4778
if (negate)
4779
opt->filter &= ~bit;
4780
else
@@ -5389,6 +5393,9 @@ static void prep_parse_options(struct diff_options *options)
5393
OPT_CALLBACK_F(0, "find-object", options, N_("<object-id>"),
5394
N_("look for differences that change the number of occurrences of the specified object"),
5395
PARSE_OPT_NONEG, diff_opt_find_object),
5396
+ OPT_CALLBACK_F(0, "diff-filter", options, N_("[(A|C|D|M|R|T|U|X|B)...[*]]"),
5397
+ N_("select files by diff type"),
5398
+ PARSE_OPT_NONEG, diff_opt_diff_filter),
5399
{ OPTION_CALLBACK, 0, "output", options, N_("<file>"),
5400
N_("Output to a specific file"),
5401
PARSE_OPT_NONEG, NULL, 0, diff_opt_output },
@@ -5441,13 +5448,6 @@ int diff_opt_parse(struct diff_options *options,
5448
}
5449
5450
/* misc options */
5444
- else if ((argcount = parse_long_opt("diff-filter", av, &optarg))) {
5445
- int offending = parse_diff_filter_opt(optarg, options);
5446
- if (offending)
5447
- die("unknown change class '%c' in --diff-filter=%s",
5448
- offending, optarg);
5449
- return argcount;
5450
- }
5451
else if (!strcmp(arg, "--no-abbrev"))
5452
options->abbrev = 0;
5453
else if (!strcmp(arg, "--abbrev"))