Subject: [PATCH v3 00/18] PCRE v1 improvements & PCRE v2 support

From: Ævar Arnfjörð Bjarmason <[email-masked]>
Date: Thu, 20 Apr 2017 21:23:27 +0000

Sorry about the high volume sending. I thought I wouldn't have time to
work on v3 for a while, but here it is a day later. I promise to hold
off on further sending for a bit.

This, unlike v2, addresses all the outstanding comments the series
had. Most importantly I added a patch at the end to remove the
concurrent support for v1 & v2 of the library as Jeff & Junio
suggested.

See the v2 coverletter in <[email-masked]> for
changes since v1, changes since v2 noted below:

Ævar Arnfjörð Bjarmason (18):
  grep: amend submodule recursion test in preparation for rx engine
    testing
  grep: add tests for grep pattern types being passed to submodules
  grep: submodule-related case statements should die if new fields are
    added

I thought there was a bug in v2 still where submodule grepping
wouldn't properly pass along e.g. `-c grep.patternType=pcre2`, this
turned out to not be the case since we pass -c options to subprocesses
via the GIT_CONFIG_PARAMETERS env var, which I didn't know about.

But in preparing to fix that I wrote these tests which improve on some
blind spots in the tests Brandon initially added for the submodule
grep. It's part of this series because it would conflict with
subsequent patches if sent stand-alone, but is otherwise unrelated.

  grep: remove redundant regflags assignment under PCRE
  Makefile & configure: reword outdated comment about PCRE

No changes.

  grep: add a test for backreferences in PCRE patterns

s/PCRE/LIBPCRE/ for the prereq check. That's changed later, but this
patch didn't work properly stand-alone, error introduced in earlier
v1-era rebasing.

  log: add exhaustive tests for pattern style options & config
  log: add -P as a synonym for --perl-regexp

No changes.

  grep & rev-list doc: stop promising libpcre for --perl-regexp

I've reworded these docs to make even weaker promises about what's a
"Perl-compatible regular expression". As noted in the commit message
the motivation is that maybe in the future we'd like to provide -P via
some entirely different library, e.g. Intel's hyperscan. This leaves
that door open without breaking existing promises in the
documentation.

  grep: make grep.patternType=[pcre|pcre1] a synonym for "perl"

Now with tests for recursive submodule grepping.

  test-lib: rename the LIBPCRE prerequisite to PCRE

Now with s/LIBPCRE/PCRE/ back for the s/PCRE/LIBPCRE/ change noted earlier.

  grep: change the internal PCRE macro names to be PCRE1
  grep: change the internal PCRE code & header names to be PCRE1
  perf: add a performance comparison test of grep -E and -P
  grep: add support for the PCRE v1 JIT API

No changes.

  grep: add support for PCRE v2

Fix one s/LIBPCREDIR/LIBPCRE2DIR/ in a ./configure notice which I
missed & tests & minor changes for recursive submodule grepping.

  grep: remove support concurrent use of both PCRE v1 & v2

NEW: Removes grep.patternType=[pcre|pcre1|pcre2] & makes trying to
compile git with both v1 & v2 an error, but either one will work, with
v1 being the default still.

After writing this up & seeing what the change is I also agree that
it's a good idea to apply this. It makes the user-facing docs simpler,
but also the various tests which previously had to worry about
[pcre|pcre1|pcre2] which now just test "perl".

  Makefile & configure: make PCRE v2 the default PCRE implementation

NEW: This changes the default PCRE implementation to v2, and makes
USE_LIBPCRE mean USE_LIBPCRE2, but USE_LIBPCRE1 is still available.

I originally wrote this as something to keep for some future
submission, but come to think of it I can't see why it shouldn't be
applied.

The v2 PCRE is stable & end-user compatible, all this change does is
change the default, someone building a new git is likely to also have
packaged PCRE v2 sometime in the last 2 years since it was released,
and if not they can choose to use the legacy v2 library by making the
trivial s/USE_LIBPCRE/USE_LIBPCRE1/ change, or package up PCRE v2.

 Documentation/git-grep.txt         |   7 +-
 Documentation/rev-list-options.txt |   9 +-
 Makefile                           |  39 +++++--
 builtin/grep.c                     |   4 +
 configure.ac                       |  81 +++++++++++---
 grep.c                             | 214 ++++++++++++++++++++++++++++++------
 grep.h                             |  32 +++++-
 revision.c                         |   2 +-
 t/README                           |   4 +-
 t/perf/p7820-grep-engines.sh       |  25 +++++
 t/t4202-log.sh                     |  86 ++++++++++++++-
 t/t7810-grep.sh                    |  41 ++++---
 t/t7812-grep-icase-non-ascii.sh    |   4 +-
 t/t7813-grep-icase-iso.sh          |  11 +-
 t/t7814-grep-recurse-submodules.sh | 215 +++++++++++++++++++++++--------------
 t/test-lib.sh                      |   3 +-
 16 files changed, 608 insertions(+), 169 deletions(-)
 create mode 100755 t/perf/p7820-grep-engines.sh

-- 
2.11.0