@@ -4613,6 +4613,43 @@ void repo_diff_setup(struct repository *r, struct diff_options *options)
4613
4613
prep_parse_options (options );
4614
4614
}
4615
4615
4616
+ static const char diff_status_letters [] = {
4617
+ DIFF_STATUS_ADDED ,
4618
+ DIFF_STATUS_COPIED ,
4619
+ DIFF_STATUS_DELETED ,
4620
+ DIFF_STATUS_MODIFIED ,
4621
+ DIFF_STATUS_RENAMED ,
4622
+ DIFF_STATUS_TYPE_CHANGED ,
4623
+ DIFF_STATUS_UNKNOWN ,
4624
+ DIFF_STATUS_UNMERGED ,
4625
+ DIFF_STATUS_FILTER_AON ,
4626
+ DIFF_STATUS_FILTER_BROKEN ,
4627
+ '\0' ,
4628
+ };
4629
+
4630
+ static unsigned int filter_bit ['Z' + 1 ];
4631
+
4632
+ static void prepare_filter_bits (void )
4633
+ {
4634
+ int i ;
4635
+
4636
+ if (!filter_bit [DIFF_STATUS_ADDED ]) {
4637
+ for (i = 0 ; diff_status_letters [i ]; i ++ )
4638
+ filter_bit [(int ) diff_status_letters [i ]] = (1 << i );
4639
+ }
4640
+ }
4641
+
4642
+ static unsigned filter_bit_tst (char status , const struct diff_options * opt )
4643
+ {
4644
+ return opt -> filter & filter_bit [(int ) status ];
4645
+ }
4646
+
4647
+ unsigned diff_filter_bit (char status )
4648
+ {
4649
+ prepare_filter_bits ();
4650
+ return filter_bit [(int ) status ];
4651
+ }
4652
+
4616
4653
void diff_setup_done (struct diff_options * options )
4617
4654
{
4618
4655
unsigned check_mask = DIFF_FORMAT_NAME |
@@ -4726,6 +4763,12 @@ void diff_setup_done(struct diff_options *options)
4726
4763
if (!options -> use_color || external_diff ())
4727
4764
options -> color_moved = 0 ;
4728
4765
4766
+ if (options -> filter_not ) {
4767
+ if (!options -> filter )
4768
+ options -> filter = ~filter_bit [DIFF_STATUS_FILTER_AON ];
4769
+ options -> filter &= ~options -> filter_not ;
4770
+ }
4771
+
4729
4772
FREE_AND_NULL (options -> parseopts );
4730
4773
}
4731
4774
@@ -4817,43 +4860,6 @@ static int parse_dirstat_opt(struct diff_options *options, const char *params)
4817
4860
return 1 ;
4818
4861
}
4819
4862
4820
- static const char diff_status_letters [] = {
4821
- DIFF_STATUS_ADDED ,
4822
- DIFF_STATUS_COPIED ,
4823
- DIFF_STATUS_DELETED ,
4824
- DIFF_STATUS_MODIFIED ,
4825
- DIFF_STATUS_RENAMED ,
4826
- DIFF_STATUS_TYPE_CHANGED ,
4827
- DIFF_STATUS_UNKNOWN ,
4828
- DIFF_STATUS_UNMERGED ,
4829
- DIFF_STATUS_FILTER_AON ,
4830
- DIFF_STATUS_FILTER_BROKEN ,
4831
- '\0' ,
4832
- };
4833
-
4834
- static unsigned int filter_bit ['Z' + 1 ];
4835
-
4836
- static void prepare_filter_bits (void )
4837
- {
4838
- int i ;
4839
-
4840
- if (!filter_bit [DIFF_STATUS_ADDED ]) {
4841
- for (i = 0 ; diff_status_letters [i ]; i ++ )
4842
- filter_bit [(int ) diff_status_letters [i ]] = (1 << i );
4843
- }
4844
- }
4845
-
4846
- static unsigned filter_bit_tst (char status , const struct diff_options * opt )
4847
- {
4848
- return opt -> filter & filter_bit [(int ) status ];
4849
- }
4850
-
4851
- unsigned diff_filter_bit (char status )
4852
- {
4853
- prepare_filter_bits ();
4854
- return filter_bit [(int ) status ];
4855
- }
4856
-
4857
4863
static int diff_opt_diff_filter (const struct option * option ,
4858
4864
const char * optarg , int unset )
4859
4865
{
@@ -4863,21 +4869,6 @@ static int diff_opt_diff_filter(const struct option *option,
4863
4869
BUG_ON_OPT_NEG (unset );
4864
4870
prepare_filter_bits ();
4865
4871
4866
- /*
4867
- * If there is a negation e.g. 'd' in the input, and we haven't
4868
- * initialized the filter field with another --diff-filter, start
4869
- * from full set of bits, except for AON.
4870
- */
4871
- if (!opt -> filter ) {
4872
- for (i = 0 ; (optch = optarg [i ]) != '\0' ; i ++ ) {
4873
- if (optch < 'a' || 'z' < optch )
4874
- continue ;
4875
- opt -> filter = (1 << (ARRAY_SIZE (diff_status_letters ) - 1 )) - 1 ;
4876
- opt -> filter &= ~filter_bit [DIFF_STATUS_FILTER_AON ];
4877
- break ;
4878
- }
4879
- }
4880
-
4881
4872
for (i = 0 ; (optch = optarg [i ]) != '\0' ; i ++ ) {
4882
4873
unsigned int bit ;
4883
4874
int negate ;
@@ -4894,7 +4885,7 @@ static int diff_opt_diff_filter(const struct option *option,
4894
4885
return error (_ ("unknown change class '%c' in --diff-filter=%s" ),
4895
4886
optarg [i ], optarg );
4896
4887
if (negate )
4897
- opt -> filter &= ~ bit ;
4888
+ opt -> filter_not |= bit ;
4898
4889
else
4899
4890
opt -> filter |= bit ;
4900
4891
}
0 commit comments