@@ -4736,10 +4736,13 @@ static unsigned filter_bit_tst(char status, const struct diff_options *opt)
4736
4736
return opt -> filter & filter_bit [(int ) status ];
4737
4737
}
4738
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 )
4740
4741
{
4742
+ struct diff_options * opt = option -> value ;
4741
4743
int i , optch ;
4742
4744
4745
+ BUG_ON_OPT_NEG (unset );
4743
4746
prepare_filter_bits ();
4744
4747
4745
4748
/*
@@ -4770,7 +4773,8 @@ static int parse_diff_filter_opt(const char *optarg, struct diff_options *opt)
4770
4773
4771
4774
bit = (0 <= optch && optch <= 'Z' ) ? filter_bit [optch ] : 0 ;
4772
4775
if (!bit )
4773
- return optarg [i ];
4776
+ return error (_ ("unknown change class '%c' in --diff-filter=%s" ),
4777
+ optarg [i ], optarg );
4774
4778
if (negate )
4775
4779
opt -> filter &= ~bit ;
4776
4780
else
@@ -5389,6 +5393,9 @@ static void prep_parse_options(struct diff_options *options)
5389
5393
OPT_CALLBACK_F (0 , "find-object" , options , N_ ("<object-id>" ),
5390
5394
N_ ("look for differences that change the number of occurrences of the specified object" ),
5391
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 ),
5392
5399
{ OPTION_CALLBACK , 0 , "output" , options , N_ ("<file>" ),
5393
5400
N_ ("Output to a specific file" ),
5394
5401
PARSE_OPT_NONEG , NULL , 0 , diff_opt_output },
@@ -5441,13 +5448,6 @@ int diff_opt_parse(struct diff_options *options,
5441
5448
}
5442
5449
5443
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
5451
else if (!strcmp (arg , "--no-abbrev" ))
5452
5452
options -> abbrev = 0 ;
5453
5453
else if (!strcmp (arg , "--abbrev" ))
0 commit comments