git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH V2 4/5] git-grep: Learn PCRE

From
Michal Kiedrowicz <michal.kiedrowicz@gmail.com>
Date
May 5, 2011, 07:41 UTC
Message-ID
<20110505094147.22e3d158@mkiedrowicz>
In-Reply-To
<4DC2418E.4070006@viscovery.net>
On 05.05.2011 08:19:58 +0200 Johannes Sixt <j.sixt@viscovery.net> wrote:
Show 15 quoted lines
> Am 5/5/2011 0:00, schrieb Michał Kiedrowicz:
> > +# Define NO_LIBPCRE if you do not have libpcre installed.
> > git-grep cannot use +# Perl-compatible regexes.
> 
> For what purpose are you adding Perl-regex when git-grep cannot use
> them?
> 
> ...
> 
> Oh! You mean to say "..., but git-grep cannot use Perl-compatible
> regexes _in this case_".
> 
> ;)
> 
> This repeats in patch 5/5.
I took this from NO_CURL and NO_EXPAT descriptions:
	 Define NO_CURL if you do not have libcurl installed.
	 git-http-pull and git-http-push are not built, and you
	 cannot use http:// and https:// transports.
	Define NO_EXPAT if you do not have expat installed.
	git-http-push is not built, and you cannot push using
	http:// and https:// transports.
But I can reword it :).
Show 11 quoted lines
> 
> > +#ifdef NO_LIBPCRE
> > +static void compile_pcre_regexp(struct grep_pat *p, struct
> > grep_opt *opt) +{
> > +	die("cannot use Perl-compatible regexes when libpcre is
> > not compiled in");
> 
> This is such a terminus technicus. Wouldn't it be much easier to read
> for Joe User if this were merely:
> 
> 	die("Perl-compatible regexes not supported");

I can argue. My message says why they aren't available, while your proposition leaves Joe without a clue :). But I'm not that much attached to it, I can change it.

Show 5 quoted lines
> 
> Also, wouldn't it be nicer to die already when the --perl-regexp
> option is detected? Then you could make these functions dummies that
> behave as if nothing was matched.
> 

I prefer to die() at lowest possible level in case someone wants to use these functions in another way (e.g. from revision-walking code).

But I can abstract these calls to die_pcre_not_supported() to not repeat die() message.

Show 14 quoted lines
> > +}
> > +
> > +static int pcrematch(struct grep_pat *p, char *line, char *eol,
> > +		regmatch_t *match, int eflags)
> > +{
> > +	die("cannot use Perl-compatible regexes when libpcre is
> > not compiled in"); +}
> > +
> > +static void free_pcre_regexp(struct grep_pat *p)
> > +{
> > +	die("cannot use Perl-compatible regexes when libpcre is
> > not compiled in"); +}
> 
> -- Hannes
Thanks for comments :)
Previous: Johannes SixtNext: Johannes Sixt
Message 10 of 16 in “Add PCRE support to git-grep”
  1. 0/5 Add PCRE support to git-grepMichał Kiedrowicz, May 4, 2011
  2. 1/5 Documentation: Add --line-number to git-grep synopsisMichał Kiedrowicz, May 4, 2011
  3. 2/5 contrib/completion: --line-number to git grepMichał Kiedrowicz, May 4, 2011
  4. 3/5 grep: Put calls to fixmatch() and regmatch() into patmatch()Michał Kiedrowicz, May 4, 2011
  5. 4/5 git-grep: Learn PCREMichał Kiedrowicz, May 4, 2011
  6. Junio C HamanoMay 5, 2011
  7. Bert WesargMay 5, 2011
  8. Junio C HamanoMay 5, 2011
  9. Johannes SixtMay 5, 2011
  10. Michal KiedrowiczMay 5, 2011
  11. Johannes SixtMay 5, 2011
  12. Michal KiedrowiczMay 5, 2011
  13. Johannes SixtMay 5, 2011
  14. Michal KiedrowiczMay 5, 2011
  15. Alex RiesenMay 5, 2011
  16. 5/5 configure: Check for libpcreMichał Kiedrowicz, May 4, 2011

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.