Skip to content

Commit d2d3f27

Browse files
pcloudsgitster
authored andcommitted
diff-parseopt: convert --diff-filter
While at it, mark one more string for translation Signed-off-by: Nguyễn Thái Ngọc Duy <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent a75f28c commit d2d3f27

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

diff.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4736,10 +4736,13 @@ static unsigned filter_bit_tst(char status, const struct diff_options *opt)
47364736
return opt->filter & filter_bit[(int) status];
47374737
}
47384738

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)
47404741
{
4742+
struct diff_options *opt = option->value;
47414743
int i, optch;
47424744

4745+
BUG_ON_OPT_NEG(unset);
47434746
prepare_filter_bits();
47444747

47454748
/*
@@ -4770,7 +4773,8 @@ static int parse_diff_filter_opt(const char *optarg, struct diff_options *opt)
47704773

47714774
bit = (0 <= optch && optch <= 'Z') ? filter_bit[optch] : 0;
47724775
if (!bit)
4773-
return optarg[i];
4776+
return error(_("unknown change class '%c' in --diff-filter=%s"),
4777+
optarg[i], optarg);
47744778
if (negate)
47754779
opt->filter &= ~bit;
47764780
else
@@ -5389,6 +5393,9 @@ static void prep_parse_options(struct diff_options *options)
53895393
OPT_CALLBACK_F(0, "find-object", options, N_("<object-id>"),
53905394
N_("look for differences that change the number of occurrences of the specified object"),
53915395
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),
53925399
{ OPTION_CALLBACK, 0, "output", options, N_("<file>"),
53935400
N_("Output to a specific file"),
53945401
PARSE_OPT_NONEG, NULL, 0, diff_opt_output },
@@ -5441,13 +5448,6 @@ int diff_opt_parse(struct diff_options *options,
54415448
}
54425449

54435450
/* 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-
}
54515451
else if (!strcmp(arg, "--no-abbrev"))
54525452
options->abbrev = 0;
54535453
else if (!strcmp(arg, "--abbrev"))

0 commit comments

Comments
 (0)