Re: [PATCH v2 2/3] diff: add -I<regex> that ignores matching changes

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



> > +-I<regex>::
> 
> Since we are mimicking other folks' feature, giving also the
> 
> --ignore-matching-lines=<regex>
> 
> synonym to that their users are familiar with would be a good idea,
> no?

Some diff implementations (e.g. the OpenBSD one) lack the long option
and I was aiming for the "greatest common divisor" for all diff
implementations, but sure, I do not see how adding the synonym could
hurt.  I will do that in v3.

> > @@ -5203,6 +5207,22 @@ static int diff_opt_patience(const struct option *opt,
> >  	return 0;
> >  }
> >  
> > +static int diff_opt_ignore_regex(const struct option *opt,
> > +				 const char *arg, int unset)
> > +{
> > +	struct diff_options *options = opt->value;
> > +	regex_t *regex;
> > +
> > +	BUG_ON_OPT_NEG(unset);
> > +	regex = xcalloc(1, sizeof(*regex));
> > +	if (regcomp(regex, arg, REG_EXTENDED | REG_NEWLINE))
> > +		die("invalid regex: %s", arg);
> > +	ALLOC_GROW(options->ignore_regex, options->ignore_regex_nr + 1,
> > +		   options->ignore_regex_alloc);
> > +	options->ignore_regex[options->ignore_regex_nr++] = regex;
> > +	return 0;
> > +}
> 
> Don't these parse-options callback functions have a way to tell the
> caller die instead of them themselves dying like this?  Would it
> work better to "return error(... message ...)", or would that give
> two error messages?

Yes, that would indeed look better, thanks - just one error message is
generated when "return error(...)" is used.  I just failed to notice
that it is a thing.  I will use it in v3.

> In anycase, this is end-user facing, so we'd
> want it to be localizable, e.g.
> 
> 	die(_("invalid regexp given to -I: '%s'", arg));
> 
> probably.

Absolutely, I will fix that in v3.  I tried to mimic what other similar
code in the tree does and a quick `git grep 'die.*regex'` yielded mostly
non-localized strings, so I settled for one as well.

-- 
Best regards,
Michał Kępień



[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux