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

[PATCH v3 0/6] Add PCRE support to git-grep

From
Michał Kiedrowicz <michal.kiedrowicz@gmail.com>
Date
May 9, 2011, 21:52 UTC
Message-ID
<1304977928-7142-1-git-send-email-michal.kiedrowicz@gmail.com>
This is the 3rd attempt to add PCRE support to git-grep.
Changes from v2:
* Replaced NO_LIBPCRE with USE_LIBPCRE. This makes libpcre support
optional. I also considered WITH_LIBPCRE but I see most #defines start
with USE_.
* Renamed 'pcre_extra *extra' with 'pcre_extra *pcre_extra_info'. Now
this variable is more descriptive.
* Reworded description of USE_LIBPCRE in Makefile and configure.ac
* I _didn't_ change the die() message to contain only "Perl-compatible
regexes not supported", but left "cannot use Perl-compatible regexes
when not compiled with USE_LIBPCRE". In my opinion this is more
informative to the user. However, it's OK for me to change that if more
people prefer shorter version.
* Removed die() from pcrematch() and free_pcre_regexp(), because die()
is first called from compile_pcre_regexp(). I left die() there and not
moved it to option parsing because I'd like to keep as few '#ifdef
USE_LIBPCRE' as possible.
* Added compile_regexp_failed() which handles both regcomp() and
pcre_compile() failures.
* Added basic testcases. I'm not sure if I should repeat all
git-grep tests with -P enabled, this seems to be officiousness. Beyond
testing -P/--perl-regexp and their interaction with -i and -w,  I also
check if `git grep -F -P` and `git grep -E -P` was called, but do not
protect from `git grep -G -P` nor `git grep -E -G -P`. Fixing this
would require changing the way -G -E are parsed (currently they
set/unset REG_EXTENDED bit in opts.regflags). Personally, if I were
fixing this, I'd remove regflags completely from grep_opt and use it
only in functions which call regcomp()/regexec() directly. That would
make code more general. But it's also possible to just convert option
parsing code to properly detect used flags. That said, I don't think the
end result is worth the effort.
I'd like to thank for all comments!
Michał Kiedrowicz (6):
  grep: Fix a typo in a comment
  grep: Extract compile_regexp_failed() from compile_regexp()
  git-grep: Learn PCRE
  configure: Check for libpcre
  grep: Add basic tests
  git-grep: Bail out when -P is used with -F or -E
 Documentation/git-grep.txt             |    6 ++
 Makefile                               |   15 +++++
 builtin/grep.c                         |    6 ++-
 config.mak.in                          |    1 +
 configure.ac                           |   40 ++++++++++++
 contrib/completion/git-completion.bash |    1 +
 grep.c                                 |  102 ++++++++++++++++++++++++++++----
 grep.h                                 |    9 +++
 t/README                               |    5 ++
 t/t7810-grep.sh                        |   54 +++++++++++++++++
 t/test-lib.sh                          |    1 +
 11 files changed, 228 insertions(+), 12 deletions(-)
-- 
1.7.3.4
Next: Michał Kiedrowicz
Message 1 of 10 in “Add PCRE support to git-grep”
  1. 0/6 Add PCRE support to git-grepMichał Kiedrowicz, May 9, 2011
  2. 1/6 grep: Fix a typo in a commentMichał Kiedrowicz, May 9, 2011
  3. 2/6 grep: Extract compile_regexp_failed() from compile_regexp()Michał Kiedrowicz, May 9, 2011
  4. 3/6 git-grep: Learn PCREMichał Kiedrowicz, May 9, 2011
  5. 4/6 configure: Check for libpcreMichał Kiedrowicz, May 9, 2011
  6. 5/6 grep: Add basic testsMichał Kiedrowicz, May 9, 2011
  7. 6/6 git-grep: Bail out when -P is used with -F or -EMichał Kiedrowicz, May 9, 2011
  8. Junio C HamanoMay 10, 2011
  9. Michal KiedrowiczMay 10, 2011
  10. Junio C HamanoMay 10, 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.