@@ -3587,6 +3587,8 @@ static void builtin_diff(const char *name_a,
35873587 if (header .len && !o -> flags .suppress_diff_headers )
35883588 ecbdata .header = & header ;
35893589 xpp .flags = o -> xdl_opts ;
3590+ xpp .ignore_regex = o -> ignore_regex ;
3591+ xpp .ignore_regex_nr = o -> ignore_regex_nr ;
35903592 xpp .anchors = o -> anchors ;
35913593 xpp .anchors_nr = o -> anchors_nr ;
35923594 xecfg .ctxlen = o -> context ;
@@ -3716,6 +3718,8 @@ static void builtin_diffstat(const char *name_a, const char *name_b,
37163718 memset (& xpp , 0 , sizeof (xpp ));
37173719 memset (& xecfg , 0 , sizeof (xecfg ));
37183720 xpp .flags = o -> xdl_opts ;
3721+ xpp .ignore_regex = o -> ignore_regex ;
3722+ xpp .ignore_regex_nr = o -> ignore_regex_nr ;
37193723 xpp .anchors = o -> anchors ;
37203724 xpp .anchors_nr = o -> anchors_nr ;
37213725 xecfg .ctxlen = o -> context ;
@@ -5203,6 +5207,22 @@ static int diff_opt_patience(const struct option *opt,
52035207 return 0 ;
52045208}
52055209
5210+ static int diff_opt_ignore_regex (const struct option * opt ,
5211+ const char * arg , int unset )
5212+ {
5213+ struct diff_options * options = opt -> value ;
5214+ regex_t * regex ;
5215+
5216+ BUG_ON_OPT_NEG (unset );
5217+ regex = xmalloc (sizeof (* regex ));
5218+ if (regcomp (regex , arg , REG_EXTENDED | REG_NEWLINE ))
5219+ return error (_ ("invalid regex given to -I: '%s'" ), arg );
5220+ ALLOC_GROW (options -> ignore_regex , options -> ignore_regex_nr + 1 ,
5221+ options -> ignore_regex_alloc );
5222+ options -> ignore_regex [options -> ignore_regex_nr ++ ] = regex ;
5223+ return 0 ;
5224+ }
5225+
52065226static int diff_opt_pickaxe_regex (const struct option * opt ,
52075227 const char * arg , int unset )
52085228{
@@ -5491,6 +5511,9 @@ static void prep_parse_options(struct diff_options *options)
54915511 OPT_BIT_F (0 , "ignore-blank-lines" , & options -> xdl_opts ,
54925512 N_ ("ignore changes whose lines are all blank" ),
54935513 XDF_IGNORE_BLANK_LINES , PARSE_OPT_NONEG ),
5514+ OPT_CALLBACK_F ('I' , "ignore-matching-lines" , options , N_ ("<regex>" ),
5515+ N_ ("ignore changes whose all lines match <regex>" ),
5516+ 0 , diff_opt_ignore_regex ),
54945517 OPT_BIT (0 , "indent-heuristic" , & options -> xdl_opts ,
54955518 N_ ("heuristic to shift diff hunk boundaries for easy reading" ),
54965519 XDF_INDENT_HEURISTIC ),
0 commit comments