{"thread":{"id":"46045","subject":"[PATCH v4 00/31] Easy to review grep & pre-PCRE changes","startedAt":"2017-05-25T19:46:01Z","lastAt":"2017-05-25T19:48:06Z","messageCount":32,"participants":["Ævar Arnfjörð Bjarmason"],"isPatch":true,"patchVersion":4,"patchTotal":31},"messages":[{"id":"320730","messageId":"20170525194535.9324-1-avarab@gmail.com","threadId":"46045","inReplyTo":null,"subject":"[PATCH v4 00/31] Easy to review grep & pre-PCRE changes","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2017-05-25T19:45:04Z","receivedAt":"2017-05-25T19:46:01Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"Easy to review? 29 (I mean 30, I mean 31) patches? Are you kidding\nme?!\n\nAs noted in v1 (<20170511091829.5634-1-avarab@gmail.com>;\nhttps://public-inbox.org/git/20170511091829.5634-1-avarab@gmail.com/)\nthese are all doc, test, refactoring etc. changes needed by the\nsubsequent \"PCRE v2, PCRE v1 JIT, log -P & fixes\" series.\n\nSee <20170520214233.7183-1-avarab@gmail.com>\n(https://public-inbox.org/git/20170520214233.7183-1-avarab@gmail.com/)\nv3 & notes about that version. What changed this time around? See\nbelow:\n\n\nÆvar Arnfjörð Bjarmason (31):\n  Makefile & configure: reword inaccurate comment about PCRE\n  grep & rev-list doc: stop promising libpcre for --perl-regexp\n  test-lib: rename the LIBPCRE prerequisite to PCRE\n  log: add exhaustive tests for pattern style options & config\n  log: make --regexp-ignore-case work with --perl-regexp\n  grep: add a test asserting that --perl-regexp dies when !PCRE\n  grep: add a test for backreferences in PCRE patterns\n  grep: change non-ASCII -i test to stop using --debug\n  grep: add tests for --threads=N and grep.threads\n  grep: amend submodule recursion test for regex engine testing\n  grep: add tests for grep pattern types being passed to submodules\n  grep: add a test helper function for less verbose -f \\0 tests\n  grep: prepare for testing binary regexes containing rx metacharacters\n  grep: add tests to fix blind spots with \\0 patterns\n\nNo changes.\n\n  perf: add a GIT_PERF_MAKE_COMMAND for when *_MAKE_OPTS won't do\n\nFix trailing whitespace.\n\n  perf: emit progress output when unpacking & building\n\nNo changes.\n\n  perf: add a comparison test of grep regex engines\n  perf: add a comparison test of grep regex engines with -F\n  perf: add a comparison test of log --grep regex engines\n  perf: add a comparison test of log --grep regex engines with -F\n\nThese are all improved:\n\n * Skip the PCRE test when we don't have the PCRE prerequisite,\n   instead of erroring out.\n\n * Update outdated commit messages left over from previous\n   submissions.\n\n * General minor nits in the code, e.g. use the same for-loop variable\n   name in all four files which have similar code, simplify the\n   test_cmp invocation etc.\n\n  grep: catch a missing enum in switch statement\n  grep: remove redundant regflags assignments\n\nNo changes.\n\n  grep: factor test for \\0 in grep patterns into a function\n\nBrandon pointed out that one of the lines in this patch was longer\nthan 79 characters. Fixed.\n\n  grep: change the internal PCRE macro names to be PCRE1\n  grep: change internal *pcre* variable & function names to be *pcre1*\n  grep: move is_fixed() earlier to avoid forward declaration\n  test-lib: add a PTHREADS prerequisite\n  pack-objects & index-pack: add test for --threads warning\n  pack-objects: fix buggy warning about threads\n  grep: given --threads with NO_PTHREADS=YesPlease, warn\n  grep: assert that threading is enabled when calling grep_{lock,unlock}\n\nNo changes.\n\n Documentation/git-grep.txt             |   7 +-\n Documentation/rev-list-options.txt     |   8 +-\n Makefile                               |  14 ++-\n builtin/grep.c                         |  23 +++-\n builtin/pack-objects.c                 |   4 +-\n configure.ac                           |  12 +-\n grep.c                                 | 110 +++++++++--------\n grep.h                                 |  10 +-\n revision.c                             |   1 +\n t/README                               |   8 +-\n t/perf/README                          |  17 ++-\n t/perf/p4220-log-grep-engines.sh       |  53 ++++++++\n t/perf/p4221-log-grep-engines-fixed.sh |  44 +++++++\n t/perf/p7820-grep-engines.sh           |  56 +++++++++\n t/perf/p7821-grep-engines-fixed.sh     |  41 +++++++\n t/perf/run                             |  13 +-\n t/t4202-log.sh                         | 160 +++++++++++++++++++++++-\n t/t5300-pack-object.sh                 |  36 ++++++\n t/t7008-grep-binary.sh                 | 135 ++++++++++++++++-----\n t/t7810-grep.sh                        |  81 ++++++++++---\n t/t7812-grep-icase-non-ascii.sh        |  29 ++---\n t/t7813-grep-icase-iso.sh              |   2 +-\n t/t7814-grep-recurse-submodules.sh     | 215 ++++++++++++++++++++-------------\n t/test-lib.sh                          |   3 +-\n 24 files changed, 843 insertions(+), 239 deletions(-)\n create mode 100755 t/perf/p4220-log-grep-engines.sh\n create mode 100755 t/perf/p4221-log-grep-engines-fixed.sh\n create mode 100755 t/perf/p7820-grep-engines.sh\n create mode 100755 t/perf/p7821-grep-engines-fixed.sh\n\n-- \n2.13.0.303.g4ebf302169\n\n"},{"id":"320731","messageId":"20170525194535.9324-2-avarab@gmail.com","threadId":"46045","inReplyTo":"20170525194535.9324-1-avarab@gmail.com","subject":"[PATCH v4 01/31] Makefile & configure: reword inaccurate comment about PCRE","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2017-05-25T19:45:05Z","receivedAt":"2017-05-25T19:46:06Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"Reword an outdated & inaccurate comment which suggests that only\ngit-grep can use PCRE.\n\nThis comment was added back when PCRE support was initially added in\ncommit 63e7e9d8b6 (\"git-grep: Learn PCRE\", 2011-05-09), and was true\nat the time.\n\nIt hasn't been telling the full truth since git-log learned to use\nPCRE with --grep in commit 727b6fc3ed (\"log --grep: accept\n--basic-regexp and --perl-regexp\", 2012-10-03), and more importantly\nis likely to get more inaccurate over time as more use is made of PCRE\nin other areas.\n\nReword it to be more future-proof, and to more clearly explain that\nthis enables user-initiated runtime behavior.\n\nCopy/pasting this so much in configure.ac is lame, these Makefile-like\nflags aren't even used by autoconf, just the corresponding\n--with[out]-* options. But copy/pasting the comments that make sense\nfor the Makefile to configure.ac where they make less sense is the\npattern everything else follows in that file. I'm not going to war\nagainst that as part of this change, just following the existing\npattern.\n\nSigned-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n---\n Makefile     |  6 ++++--\n configure.ac | 12 ++++++++----\n 2 files changed, 12 insertions(+), 6 deletions(-)\n\ndiff --git a/Makefile b/Makefile\nindex e35542e631..eedadb8056 100644\n--- a/Makefile\n+++ b/Makefile\n@@ -24,8 +24,10 @@ all::\n # Define NO_OPENSSL environment variable if you do not have OpenSSL.\n # This also implies BLK_SHA1.\n #\n-# Define USE_LIBPCRE if you have and want to use libpcre. git-grep will be\n-# able to use Perl-compatible regular expressions.\n+# Define USE_LIBPCRE if you have and want to use libpcre. Various\n+# commands such as log and grep offer runtime options to use\n+# Perl-compatible regular expressions instead of standard or extended\n+# POSIX regular expressions.\n #\n # Define LIBPCREDIR=/foo/bar if your libpcre header and library files are in\n # /foo/bar/include and /foo/bar/lib directories.\ndiff --git a/configure.ac b/configure.ac\nindex 128165529f..deeb968daa 100644\n--- a/configure.ac\n+++ b/configure.ac\n@@ -250,8 +250,10 @@ AS_HELP_STRING([--with-openssl],[use OpenSSL library (default is YES)])\n AS_HELP_STRING([],              [ARG can be prefix for openssl library and headers]),\n GIT_PARSE_WITH([openssl]))\n \n-# Define USE_LIBPCRE if you have and want to use libpcre. git-grep will be\n-# able to use Perl-compatible regular expressions.\n+# Define USE_LIBPCRE if you have and want to use libpcre. Various\n+# commands such as log and grep offer runtime options to use\n+# Perl-compatible regular expressions instead of standard or extended\n+# POSIX regular expressions.\n #\n # Define LIBPCREDIR=/foo/bar if your libpcre header and library files are in\n # /foo/bar/include and /foo/bar/lib directories.\n@@ -499,8 +501,10 @@ GIT_CONF_SUBST([NEEDS_SSL_WITH_CRYPTO])\n GIT_CONF_SUBST([NO_OPENSSL])\n \n #\n-# Define USE_LIBPCRE if you have and want to use libpcre. git-grep will be\n-# able to use Perl-compatible regular expressions.\n+# Define USE_LIBPCRE if you have and want to use libpcre. Various\n+# commands such as log and grep offer runtime options to use\n+# Perl-compatible regular expressions instead of standard or extended\n+# POSIX regular expressions.\n #\n \n if test -n \"$USE_LIBPCRE\"; then\n-- \n2.13.0.303.g4ebf302169\n\n"},{"id":"320732","messageId":"20170525194535.9324-3-avarab@gmail.com","threadId":"46045","inReplyTo":"20170525194535.9324-1-avarab@gmail.com","subject":"[PATCH v4 02/31] grep & rev-list doc: stop promising libpcre for --perl-regexp","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2017-05-25T19:45:06Z","receivedAt":"2017-05-25T19:46:09Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"Stop promising in our grep & rev-list options documentation that we're\nalways going to be using libpcre when given the --perl-regexp option.\n\nInstead talk about using \"Perl-compatible regular expressions\" and\nusing these types of patterns using \"a compile-time dependency\".\n\nSaying \"libpcre\" means that we're talking about libpcre.so, which is\nalways going to be v1. This change is part of an ongoing saga to add\nsupport for libpcre2, which comes with PCRE v2.\n\nIn the future we might use some completely unrelated library to\nprovide perl-compatible regular expression support. By wording the\ndocumentation differently and not promising any specific version of\nPCRE or even PCRE at all we have more wiggle room to change the\nimplementation.\n\nSigned-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n---\n Documentation/git-grep.txt         | 7 +++++--\n Documentation/rev-list-options.txt | 8 ++++++--\n 2 files changed, 11 insertions(+), 4 deletions(-)\n\ndiff --git a/Documentation/git-grep.txt b/Documentation/git-grep.txt\nindex 71f32f3508..5033483db4 100644\n--- a/Documentation/git-grep.txt\n+++ b/Documentation/git-grep.txt\n@@ -161,8 +161,11 @@ OPTIONS\n \n -P::\n --perl-regexp::\n-\tUse Perl-compatible regexp for patterns. Requires libpcre to be\n-\tcompiled in.\n+\tUse Perl-compatible regular expressions for patterns.\n++\n+Support for these types of regular expressions is an optional\n+compile-time dependency. If Git wasn't compiled with support for them\n+providing this option will cause it to die.\n \n -F::\n --fixed-strings::\ndiff --git a/Documentation/rev-list-options.txt b/Documentation/rev-list-options.txt\nindex a02f7324c0..a46f70c2b1 100644\n--- a/Documentation/rev-list-options.txt\n+++ b/Documentation/rev-list-options.txt\n@@ -92,8 +92,12 @@ endif::git-rev-list[]\n \tpattern as a regular expression).\n \n --perl-regexp::\n-\tConsider the limiting patterns to be Perl-compatible regular expressions.\n-\tRequires libpcre to be compiled in.\n+\tConsider the limiting patterns to be Perl-compatible regular\n+\texpressions.\n++\n+Support for these types of regular expressions is an optional\n+compile-time dependency. If Git wasn't compiled with support for them\n+providing this option will cause it to die.\n \n --remove-empty::\n \tStop when a given path disappears from the tree.\n-- \n2.13.0.303.g4ebf302169\n\n"},{"id":"320733","messageId":"20170525194535.9324-5-avarab@gmail.com","threadId":"46045","inReplyTo":"20170525194535.9324-1-avarab@gmail.com","subject":"[PATCH v4 04/31] log: add exhaustive tests for pattern style options & config","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2017-05-25T19:45:08Z","receivedAt":"2017-05-25T19:46:12Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"Add exhaustive tests for how the different grep.patternType options &\nthe corresponding command-line options affect git-log.\n\nBefore this change it was possible to patch revision.c so that the\n--basic-regexp option was synonymous with --extended-regexp, and\n--perl-regexp wasn't recognized at all, and still have 100% of the\ntest suite pass.\n\nThis was because the first test being modified here, added in commit\n34a4ae55b2 (\"log --grep: use the same helper to set -E/-F options as\n\"git grep\"\", 2012-10-03), didn't actually check whether we'd enabled\nextended regular expressions as distinct from re-toggling non-fixed\nstring support.\n\nFix that by changing the pattern to a pattern that'll only match if\n--extended-regexp option is provided, but won't match under the\ndefault --basic-regexp option.\n\nOther potential regressions were possible since there were no tests\nfor the rest of the combinations of grep.patternType configuration\ntoggles & corresponding git-log command-line options. Add exhaustive\ntests for those.\n\nThe patterns being passed to fixed/basic/extended/PCRE are carefully\ncrafted to return the wrong thing if the grep engine were to pick any\nother matching method than the one it's told to use.\n\nSigned-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n---\n t/t4202-log.sh | 98 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++-\n 1 file changed, 97 insertions(+), 1 deletion(-)\n\ndiff --git a/t/t4202-log.sh b/t/t4202-log.sh\nindex 1c7d6729c6..948fd719d2 100755\n--- a/t/t4202-log.sh\n+++ b/t/t4202-log.sh\n@@ -262,7 +262,30 @@ test_expect_success 'log --grep -i' '\n \n test_expect_success 'log -F -E --grep=<ere> uses ere' '\n \techo second >expect &&\n-\tgit log -1 --pretty=\"tformat:%s\" -F -E --grep=s.c.nd >actual &&\n+\t# basic would need \\(s\\) to do the same\n+\tgit log -1 --pretty=\"tformat:%s\" -F -E --grep=\"(s).c.nd\" >actual &&\n+\ttest_cmp expect actual\n+'\n+\n+test_expect_success PCRE 'log -F -E --perl-regexp --grep=<pcre> uses PCRE' '\n+\ttest_when_finished \"rm -rf num_commits\" &&\n+\tgit init num_commits &&\n+\t(\n+\t\tcd num_commits &&\n+\t\ttest_commit 1d &&\n+\t\ttest_commit 2e\n+\t) &&\n+\n+\t# In PCRE \\d in [\\d] is like saying \"0-9\", and matches the 2\n+\t# in 2e...\n+\techo 2e >expect &&\n+\tgit -C num_commits log -1 --pretty=\"tformat:%s\" -F -E --perl-regexp --grep=\"[\\d]\" >actual &&\n+\ttest_cmp expect actual &&\n+\n+\t# ...in POSIX basic and extended it is the same as [d],\n+\t# i.e. \"d\", which matches 1d, but does not match 2e.\n+\techo 1d >expect &&\n+\tgit -C num_commits log -1 --pretty=\"tformat:%s\" -F -E --grep=\"[\\d]\" >actual &&\n \ttest_cmp expect actual\n '\n \n@@ -280,6 +303,79 @@ test_expect_success 'log with grep.patternType configuration and command line' '\n \ttest_cmp expect actual\n '\n \n+test_expect_success 'log with various grep.patternType configurations & command-lines' '\n+\tgit init pattern-type &&\n+\t(\n+\t\tcd pattern-type &&\n+\t\ttest_commit 1 file A &&\n+\n+\t\t# The tagname is overridden here because creating a\n+\t\t# tag called \"(1|2)\" as test_commit would otherwise\n+\t\t# implicitly do would fail on e.g. MINGW.\n+\t\ttest_commit \"(1|2)\" file B 2 &&\n+\n+\t\techo \"(1|2)\" >expect.fixed &&\n+\t\tcp expect.fixed expect.basic &&\n+\t\tcp expect.fixed expect.extended &&\n+\t\tcp expect.fixed expect.perl &&\n+\n+\t\t# A strcmp-like match with fixed.\n+\t\tgit -c grep.patternType=fixed log --pretty=tformat:%s \\\n+\t\t\t--grep=\"(1|2)\" >actual.fixed &&\n+\n+\t\t# POSIX basic matches (, | and ) literally.\n+\t\tgit -c grep.patternType=basic log --pretty=tformat:%s \\\n+\t\t\t--grep=\"(.|.)\" >actual.basic &&\n+\n+\t\t# POSIX extended needs to have | escaped to match it\n+\t\t# literally, whereas under basic this is the same as\n+\t\t# (|2), i.e. it would also match \"1\". This test checks\n+\t\t# for extended by asserting that it is not matching\n+\t\t# what basic would match.\n+\t\tgit -c grep.patternType=extended log --pretty=tformat:%s \\\n+\t\t\t--grep=\"\\|2\" >actual.extended &&\n+\t\tif test_have_prereq PCRE\n+\t\tthen\n+\t\t\t# Only PCRE would match [\\d]\\| with only\n+\t\t\t# \"(1|2)\" due to [\\d]. POSIX basic would match\n+\t\t\t# both it and \"1\" since similarly to the\n+\t\t\t# extended match above it is the same as\n+\t\t\t# \\([\\d]\\|\\). POSIX extended would\n+\t\t\t# match neither.\n+\t\t\tgit -c grep.patternType=perl log --pretty=tformat:%s \\\n+\t\t\t\t--grep=\"[\\d]\\|\" >actual.perl &&\n+\t\t\ttest_cmp expect.perl actual.perl\n+\t\tfi &&\n+\t\ttest_cmp expect.fixed actual.fixed &&\n+\t\ttest_cmp expect.basic actual.basic &&\n+\t\ttest_cmp expect.extended actual.extended &&\n+\n+\t\tgit log --pretty=tformat:%s -F \\\n+\t\t\t--grep=\"(1|2)\" >actual.fixed.short-arg &&\n+\t\tgit log --pretty=tformat:%s -E \\\n+\t\t\t--grep=\"\\|2\" >actual.extended.short-arg &&\n+\t\ttest_cmp expect.fixed actual.fixed.short-arg &&\n+\t\ttest_cmp expect.extended actual.extended.short-arg &&\n+\n+\t\tgit log --pretty=tformat:%s --fixed-strings \\\n+\t\t\t--grep=\"(1|2)\" >actual.fixed.long-arg &&\n+\t\tgit log --pretty=tformat:%s --basic-regexp \\\n+\t\t\t--grep=\"(.|.)\" >actual.basic.long-arg &&\n+\t\tgit log --pretty=tformat:%s --extended-regexp \\\n+\t\t\t--grep=\"\\|2\" >actual.extended.long-arg &&\n+\t\tif test_have_prereq PCRE\n+\t\tthen\n+\t\t\tgit log --pretty=tformat:%s --perl-regexp \\\n+\t\t\t\t--grep=\"[\\d]\\|\" >actual.perl.long-arg &&\n+\t\t\ttest_cmp expect.perl actual.perl.long-arg\n+\n+\t\tfi &&\n+\t\ttest_cmp expect.fixed actual.fixed.long-arg &&\n+\t\ttest_cmp expect.basic actual.basic.long-arg &&\n+\t\ttest_cmp expect.extended actual.extended.long-arg\n+\t)\n+'\n+\n cat > expect <<EOF\n * Second\n * sixth\n-- \n2.13.0.303.g4ebf302169\n\n"},{"id":"320734","messageId":"20170525194535.9324-4-avarab@gmail.com","threadId":"46045","inReplyTo":"20170525194535.9324-1-avarab@gmail.com","subject":"[PATCH v4 03/31] test-lib: rename the LIBPCRE prerequisite to PCRE","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2017-05-25T19:45:07Z","receivedAt":"2017-05-25T19:46:16Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"Rename the LIBPCRE prerequisite to PCRE. This is for preparation for\nlibpcre2 support, where having just \"LIBPCRE\" would be confusing as it\nimplies v1 of the library.\n\nNone of these tests are incompatible between versions 1 & 2 of\nlibpcre, it's less confusing to give them a more general name to make\nit clear that they work on both library versions.\n\nSigned-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n---\n t/README                        |  4 ++--\n t/t7810-grep.sh                 | 28 ++++++++++++++--------------\n t/t7812-grep-icase-non-ascii.sh |  4 ++--\n t/t7813-grep-icase-iso.sh       |  2 +-\n t/test-lib.sh                   |  2 +-\n 5 files changed, 20 insertions(+), 20 deletions(-)\n\ndiff --git a/t/README b/t/README\nindex ab386c3681..a90cb62583 100644\n--- a/t/README\n+++ b/t/README\n@@ -803,9 +803,9 @@ use these, and \"test_set_prereq\" for how to define your own.\n    Test is not run by root user, and an attempt to write to an\n    unwritable file is expected to fail correctly.\n \n- - LIBPCRE\n+ - PCRE\n \n-   Git was compiled with USE_LIBPCRE=YesPlease. Wrap any tests\n+   Git was compiled with support for PCRE. Wrap any tests\n    that use git-grep --perl-regexp or git-grep -P in these.\n \n  - CASE_INSENSITIVE_FS\ndiff --git a/t/t7810-grep.sh b/t/t7810-grep.sh\nindex cee42097b0..c84c4d99f9 100755\n--- a/t/t7810-grep.sh\n+++ b/t/t7810-grep.sh\n@@ -275,7 +275,7 @@ do\n \t\ttest_cmp expected actual\n \t'\n \n-\ttest_expect_success LIBPCRE \"grep $L with grep.patterntype=perl\" '\n+\ttest_expect_success PCRE \"grep $L with grep.patterntype=perl\" '\n \t\techo \"${HC}ab:a+b*c\" >expected &&\n \t\tgit -c grep.patterntype=perl grep \"a\\x{2b}b\\x{2a}c\" $H ab >actual &&\n \t\ttest_cmp expected actual\n@@ -1053,12 +1053,12 @@ hello.c:int main(int argc, const char **argv)\n hello.c:\tprintf(\"Hello world.\\n\");\n EOF\n \n-test_expect_success LIBPCRE 'grep --perl-regexp pattern' '\n+test_expect_success PCRE 'grep --perl-regexp pattern' '\n \tgit grep --perl-regexp \"\\p{Ps}.*?\\p{Pe}\" hello.c >actual &&\n \ttest_cmp expected actual\n '\n \n-test_expect_success LIBPCRE 'grep -P pattern' '\n+test_expect_success PCRE 'grep -P pattern' '\n \tgit grep -P \"\\p{Ps}.*?\\p{Pe}\" hello.c >actual &&\n \ttest_cmp expected actual\n '\n@@ -1070,13 +1070,13 @@ test_expect_success 'grep pattern with grep.extendedRegexp=true' '\n \ttest_cmp empty actual\n '\n \n-test_expect_success LIBPCRE 'grep -P pattern with grep.extendedRegexp=true' '\n+test_expect_success PCRE 'grep -P pattern with grep.extendedRegexp=true' '\n \tgit -c grep.extendedregexp=true \\\n \t\tgrep -P \"\\p{Ps}.*?\\p{Pe}\" hello.c >actual &&\n \ttest_cmp expected actual\n '\n \n-test_expect_success LIBPCRE 'grep -P -v pattern' '\n+test_expect_success PCRE 'grep -P -v pattern' '\n \t{\n \t\techo \"ab:a+b*c\"\n \t\techo \"ab:a+bc\"\n@@ -1085,7 +1085,7 @@ test_expect_success LIBPCRE 'grep -P -v pattern' '\n \ttest_cmp expected actual\n '\n \n-test_expect_success LIBPCRE 'grep -P -i pattern' '\n+test_expect_success PCRE 'grep -P -i pattern' '\n \tcat >expected <<-EOF &&\n \thello.c:\tprintf(\"Hello world.\\n\");\n \tEOF\n@@ -1093,7 +1093,7 @@ test_expect_success LIBPCRE 'grep -P -i pattern' '\n \ttest_cmp expected actual\n '\n \n-test_expect_success LIBPCRE 'grep -P -w pattern' '\n+test_expect_success PCRE 'grep -P -w pattern' '\n \t{\n \t\techo \"hello_world:Hello world\"\n \t\techo \"hello_world:HeLLo world\"\n@@ -1118,11 +1118,11 @@ test_expect_success 'grep invalidpattern properly dies with grep.patternType=ext\n \ttest_must_fail git -c grep.patterntype=extended grep \"a[\"\n '\n \n-test_expect_success LIBPCRE 'grep -P invalidpattern properly dies ' '\n+test_expect_success PCRE 'grep -P invalidpattern properly dies ' '\n \ttest_must_fail git grep -P \"a[\"\n '\n \n-test_expect_success LIBPCRE 'grep invalidpattern properly dies with grep.patternType=perl' '\n+test_expect_success PCRE 'grep invalidpattern properly dies with grep.patternType=perl' '\n \ttest_must_fail git -c grep.patterntype=perl grep \"a[\"\n '\n \n@@ -1191,13 +1191,13 @@ test_expect_success 'grep pattern with grep.patternType=fixed, =basic, =perl, =e\n \ttest_cmp expected actual\n '\n \n-test_expect_success LIBPCRE 'grep -G -F -E -P pattern' '\n+test_expect_success PCRE 'grep -G -F -E -P pattern' '\n \techo \"d0:0\" >expected &&\n \tgit grep -G -F -E -P \"[\\d]\" d0 >actual &&\n \ttest_cmp expected actual\n '\n \n-test_expect_success LIBPCRE 'grep pattern with grep.patternType=fixed, =basic, =extended, =perl' '\n+test_expect_success PCRE 'grep pattern with grep.patternType=fixed, =basic, =extended, =perl' '\n \techo \"d0:0\" >expected &&\n \tgit \\\n \t\t-c grep.patterntype=fixed \\\n@@ -1208,7 +1208,7 @@ test_expect_success LIBPCRE 'grep pattern with grep.patternType=fixed, =basic, =\n \ttest_cmp expected actual\n '\n \n-test_expect_success LIBPCRE 'grep -P pattern with grep.patternType=fixed' '\n+test_expect_success PCRE 'grep -P pattern with grep.patternType=fixed' '\n \techo \"ab:a+b*c\" >expected &&\n \tgit \\\n \t\t-c grep.patterntype=fixed \\\n@@ -1343,12 +1343,12 @@ space: line with leading space2\n space: line with leading space3\n EOF\n \n-test_expect_success LIBPCRE 'grep -E \"^ \"' '\n+test_expect_success PCRE 'grep -E \"^ \"' '\n \tgit grep -E \"^ \" space >actual &&\n \ttest_cmp expected actual\n '\n \n-test_expect_success LIBPCRE 'grep -P \"^ \"' '\n+test_expect_success PCRE 'grep -P \"^ \"' '\n \tgit grep -P \"^ \" space >actual &&\n \ttest_cmp expected actual\n '\ndiff --git a/t/t7812-grep-icase-non-ascii.sh b/t/t7812-grep-icase-non-ascii.sh\nindex 169fd8d706..04a61cb8e0 100755\n--- a/t/t7812-grep-icase-non-ascii.sh\n+++ b/t/t7812-grep-icase-non-ascii.sh\n@@ -20,13 +20,13 @@ test_expect_success REGEX_LOCALE 'grep literal string, no -F' '\n \tgit grep -i \"TILRAUN: HALLÓ HEIMUR!\"\n '\n \n-test_expect_success GETTEXT_LOCALE,LIBPCRE 'grep pcre utf-8 icase' '\n+test_expect_success GETTEXT_LOCALE,PCRE 'grep pcre utf-8 icase' '\n \tgit grep --perl-regexp    \"TILRAUN: H.lló Heimur!\" &&\n \tgit grep --perl-regexp -i \"TILRAUN: H.lló Heimur!\" &&\n \tgit grep --perl-regexp -i \"TILRAUN: H.LLÓ HEIMUR!\"\n '\n \n-test_expect_success GETTEXT_LOCALE,LIBPCRE 'grep pcre utf-8 string with \"+\"' '\n+test_expect_success GETTEXT_LOCALE,PCRE 'grep pcre utf-8 string with \"+\"' '\n \ttest_write_lines \"TILRAUN: Hallóó Heimur!\" >file2 &&\n \tgit add file2 &&\n \tgit grep -l --perl-regexp \"TILRAUN: H.lló+ Heimur!\" >actual &&\ndiff --git a/t/t7813-grep-icase-iso.sh b/t/t7813-grep-icase-iso.sh\nindex efef7fb81f..701e08a8e5 100755\n--- a/t/t7813-grep-icase-iso.sh\n+++ b/t/t7813-grep-icase-iso.sh\n@@ -11,7 +11,7 @@ test_expect_success GETTEXT_ISO_LOCALE 'setup' '\n \texport LC_ALL\n '\n \n-test_expect_success GETTEXT_ISO_LOCALE,LIBPCRE 'grep pcre string' '\n+test_expect_success GETTEXT_ISO_LOCALE,PCRE 'grep pcre string' '\n \tgit grep --perl-regexp -i \"TILRAUN: H.ll� Heimur!\" &&\n \tgit grep --perl-regexp -i \"TILRAUN: H.LL� HEIMUR!\"\n '\ndiff --git a/t/test-lib.sh b/t/test-lib.sh\nindex 26b3edfb2e..04d857a42b 100644\n--- a/t/test-lib.sh\n+++ b/t/test-lib.sh\n@@ -1014,7 +1014,7 @@ esac\n ( COLUMNS=1 && test $COLUMNS = 1 ) && test_set_prereq COLUMNS_CAN_BE_1\n test -z \"$NO_PERL\" && test_set_prereq PERL\n test -z \"$NO_PYTHON\" && test_set_prereq PYTHON\n-test -n \"$USE_LIBPCRE\" && test_set_prereq LIBPCRE\n+test -n \"$USE_LIBPCRE\" && test_set_prereq PCRE\n test -z \"$NO_GETTEXT\" && test_set_prereq GETTEXT\n \n # Can we rely on git's output in the C locale?\n-- \n2.13.0.303.g4ebf302169\n\n"},{"id":"320735","messageId":"20170525194535.9324-6-avarab@gmail.com","threadId":"46045","inReplyTo":"20170525194535.9324-1-avarab@gmail.com","subject":"[PATCH v4 05/31] log: make --regexp-ignore-case work with --perl-regexp","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2017-05-25T19:45:09Z","receivedAt":"2017-05-25T19:46:18Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"Make the --regexp-ignore-case option work with --perl-regexp. This\nnever worked, and there was no test for this. Fix the bug and add a\ntest.\n\nWhen PCRE support was added in commit 63e7e9d8b6 (\"git-grep: Learn\nPCRE\", 2011-05-09) compile_pcre_regexp() would only check\nopt->ignore_case, but when the --perl-regexp option was added in\ncommit 727b6fc3ed (\"log --grep: accept --basic-regexp and\n--perl-regexp\", 2012-10-03) the code didn't set the opt->ignore_case.\n\nChange the test suite to test for -i and --invert-regexp with\nbasic/extended/perl patterns in addition to fixed, which was the only\npatternType that was tested for before in combination with those\noptions.\n\nSigned-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n---\n revision.c     |  1 +\n t/t4202-log.sh | 60 +++++++++++++++++++++++++++++++++++++++++++++++++++++-----\n 2 files changed, 56 insertions(+), 5 deletions(-)\n\ndiff --git a/revision.c b/revision.c\nindex 8a8c1789c7..4883cdd2d0 100644\n--- a/revision.c\n+++ b/revision.c\n@@ -1991,6 +1991,7 @@ static int handle_revision_opt(struct rev_info *revs, int argc, const char **arg\n \t} else if (!strcmp(arg, \"--extended-regexp\") || !strcmp(arg, \"-E\")) {\n \t\trevs->grep_filter.pattern_type_option = GREP_PATTERN_TYPE_ERE;\n \t} else if (!strcmp(arg, \"--regexp-ignore-case\") || !strcmp(arg, \"-i\")) {\n+\t\trevs->grep_filter.ignore_case = 1;\n \t\trevs->grep_filter.regflags |= REG_ICASE;\n \t\tDIFF_OPT_SET(&revs->diffopt, PICKAXE_IGNORE_CASE);\n \t} else if (!strcmp(arg, \"--fixed-strings\") || !strcmp(arg, \"-F\")) {\ndiff --git a/t/t4202-log.sh b/t/t4202-log.sh\nindex 948fd719d2..c25eb9afd1 100755\n--- a/t/t4202-log.sh\n+++ b/t/t4202-log.sh\n@@ -231,14 +231,47 @@ second\n initial\n EOF\n test_expect_success 'log --invert-grep --grep' '\n-\tgit log --pretty=\"tformat:%s\" --invert-grep --grep=th --grep=Sec >actual &&\n-\ttest_cmp expect actual\n+\t# Fixed\n+\tgit -c grep.patternType=fixed log --pretty=\"tformat:%s\" --invert-grep --grep=th --grep=Sec >actual &&\n+\ttest_cmp expect actual &&\n+\n+\t# POSIX basic\n+\tgit -c grep.patternType=basic log --pretty=\"tformat:%s\" --invert-grep --grep=t[h] --grep=S[e]c >actual &&\n+\ttest_cmp expect actual &&\n+\n+\t# POSIX extended\n+\tgit -c grep.patternType=basic log --pretty=\"tformat:%s\" --invert-grep --grep=t[h] --grep=S[e]c >actual &&\n+\ttest_cmp expect actual &&\n+\n+\t# PCRE\n+\tif test_have_prereq PCRE\n+\tthen\n+\t\tgit -c grep.patternType=perl log --pretty=\"tformat:%s\" --invert-grep --grep=t[h] --grep=S[e]c >actual &&\n+\t\ttest_cmp expect actual\n+\tfi\n '\n \n test_expect_success 'log --invert-grep --grep -i' '\n \techo initial >expect &&\n-\tgit log --pretty=\"tformat:%s\" --invert-grep -i --grep=th --grep=Sec >actual &&\n-\ttest_cmp expect actual\n+\n+\t# Fixed\n+\tgit -c grep.patternType=fixed log --pretty=\"tformat:%s\" --invert-grep -i --grep=th --grep=Sec >actual &&\n+\ttest_cmp expect actual &&\n+\n+\t# POSIX basic\n+\tgit -c grep.patternType=basic log --pretty=\"tformat:%s\" --invert-grep -i --grep=t[h] --grep=S[e]c >actual &&\n+\ttest_cmp expect actual &&\n+\n+\t# POSIX extended\n+\tgit -c grep.patternType=extended log --pretty=\"tformat:%s\" --invert-grep -i --grep=t[h] --grep=S[e]c >actual &&\n+\ttest_cmp expect actual &&\n+\n+\t# PCRE\n+\tif test_have_prereq PCRE\n+\tthen\n+\t\tgit -c grep.patternType=perl log --pretty=\"tformat:%s\" --invert-grep -i --grep=t[h] --grep=S[e]c >actual &&\n+\t\ttest_cmp expect actual\n+\tfi\n '\n \n test_expect_success 'log --grep option parsing' '\n@@ -256,8 +289,25 @@ test_expect_success 'log -i --grep' '\n \n test_expect_success 'log --grep -i' '\n \techo Second >expect &&\n+\n+\t# Fixed\n \tgit log -1 --pretty=\"tformat:%s\" --grep=sec -i >actual &&\n-\ttest_cmp expect actual\n+\ttest_cmp expect actual &&\n+\n+\t# POSIX basic\n+\tgit -c grep.patternType=basic log -1 --pretty=\"tformat:%s\" --grep=s[e]c -i >actual &&\n+\ttest_cmp expect actual &&\n+\n+\t# POSIX extended\n+\tgit -c grep.patternType=extended log -1 --pretty=\"tformat:%s\" --grep=s[e]c -i >actual &&\n+\ttest_cmp expect actual &&\n+\n+\t# PCRE\n+\tif test_have_prereq PCRE\n+\tthen\n+\t\tgit -c grep.patternType=perl log -1 --pretty=\"tformat:%s\" --grep=s[e]c -i >actual &&\n+\t\ttest_cmp expect actual\n+\tfi\n '\n \n test_expect_success 'log -F -E --grep=<ere> uses ere' '\n-- \n2.13.0.303.g4ebf302169\n\n"},{"id":"320736","messageId":"20170525194535.9324-8-avarab@gmail.com","threadId":"46045","inReplyTo":"20170525194535.9324-1-avarab@gmail.com","subject":"[PATCH v4 07/31] grep: add a test for backreferences in PCRE patterns","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2017-05-25T19:45:11Z","receivedAt":"2017-05-25T19:46:25Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"Add a test for backreferences such as (.)\\1 in PCRE patterns. This\ntest ensures that the PCRE_NO_AUTO_CAPTURE option isn't turned\non. Before this change turning it on would break these sort of\npatterns, but wouldn't break any tests.\n\nSigned-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n---\n t/t7810-grep.sh | 7 +++++++\n 1 file changed, 7 insertions(+)\n\ndiff --git a/t/t7810-grep.sh b/t/t7810-grep.sh\nindex 8d69113695..daa906b9b0 100755\n--- a/t/t7810-grep.sh\n+++ b/t/t7810-grep.sh\n@@ -1114,6 +1114,13 @@ test_expect_success PCRE 'grep -P -w pattern' '\n \ttest_cmp expected actual\n '\n \n+test_expect_success PCRE 'grep -P backreferences work (the PCRE NO_AUTO_CAPTURE flag is not set)' '\n+\tgit grep -P -h \"(?P<one>.)(?P=one)\" hello_world >actual &&\n+\ttest_cmp hello_world actual &&\n+\tgit grep -P -h \"(.)\\1\" hello_world >actual &&\n+\ttest_cmp hello_world actual\n+'\n+\n test_expect_success 'grep -G invalidpattern properly dies ' '\n \ttest_must_fail git grep -G \"a[\"\n '\n-- \n2.13.0.303.g4ebf302169\n\n"},{"id":"320737","messageId":"20170525194535.9324-9-avarab@gmail.com","threadId":"46045","inReplyTo":"20170525194535.9324-1-avarab@gmail.com","subject":"[PATCH v4 08/31] grep: change non-ASCII -i test to stop using --debug","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2017-05-25T19:45:12Z","receivedAt":"2017-05-25T19:46:33Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"Change a non-ASCII case-insensitive test case to stop using --debug,\nand instead simply test for the expected results.\n\nThe test coverage remains the same with this change, but the test\nwon't break due to internal refactoring.\n\nThis test was added in commit 793dc676e0 (\"grep/icase: avoid kwsset\nwhen -F is specified\", 2016-06-25). It was asserting that the regex\nmust be compiled with compile_fixed_regexp(), instead test for the\nexpected results, allowing the underlying implementation to change.\n\nSigned-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n---\n t/t7812-grep-icase-non-ascii.sh | 25 +++++--------------------\n 1 file changed, 5 insertions(+), 20 deletions(-)\n\ndiff --git a/t/t7812-grep-icase-non-ascii.sh b/t/t7812-grep-icase-non-ascii.sh\nindex 04a61cb8e0..0059a1f837 100755\n--- a/t/t7812-grep-icase-non-ascii.sh\n+++ b/t/t7812-grep-icase-non-ascii.sh\n@@ -36,29 +36,14 @@ test_expect_success GETTEXT_LOCALE,PCRE 'grep pcre utf-8 string with \"+\"' '\n '\n \n test_expect_success REGEX_LOCALE 'grep literal string, with -F' '\n-\tgit grep --debug -i -F \"TILRAUN: Halló Heimur!\"  2>&1 >/dev/null |\n-\t\t grep fixed >debug1 &&\n-\ttest_write_lines \"fixed TILRAUN: Halló Heimur!\" >expect1 &&\n-\ttest_cmp expect1 debug1 &&\n-\n-\tgit grep --debug -i -F \"TILRAUN: HALLÓ HEIMUR!\"  2>&1 >/dev/null |\n-\t\t grep fixed >debug2 &&\n-\ttest_write_lines \"fixed TILRAUN: HALLÓ HEIMUR!\" >expect2 &&\n-\ttest_cmp expect2 debug2\n+\tgit grep -i -F \"TILRAUN: Halló Heimur!\" &&\n+\tgit grep -i -F \"TILRAUN: HALLÓ HEIMUR!\"\n '\n \n test_expect_success REGEX_LOCALE 'grep string with regex, with -F' '\n-\ttest_write_lines \"^*TILR^AUN:.* \\\\Halló \\$He[]imur!\\$\" >file &&\n-\n-\tgit grep --debug -i -F \"^*TILR^AUN:.* \\\\Halló \\$He[]imur!\\$\" 2>&1 >/dev/null |\n-\t\t grep fixed >debug1 &&\n-\ttest_write_lines \"fixed \\\\^*TILR^AUN:\\\\.\\\\* \\\\\\\\Halló \\$He\\\\[]imur!\\\\\\$\" >expect1 &&\n-\ttest_cmp expect1 debug1 &&\n-\n-\tgit grep --debug -i -F \"^*TILR^AUN:.* \\\\HALLÓ \\$HE[]IMUR!\\$\"  2>&1 >/dev/null |\n-\t\t grep fixed >debug2 &&\n-\ttest_write_lines \"fixed \\\\^*TILR^AUN:\\\\.\\\\* \\\\\\\\HALLÓ \\$HE\\\\[]IMUR!\\\\\\$\" >expect2 &&\n-\ttest_cmp expect2 debug2\n+\ttest_write_lines \"TILRAUN: Halló Heimur [abc]!\" >file3 &&\n+\tgit add file3 &&\n+\tgit grep -i -F \"TILRAUN: Halló Heimur [abc]!\" file3\n '\n \n test_expect_success REGEX_LOCALE 'pickaxe -i on non-ascii' '\n-- \n2.13.0.303.g4ebf302169\n\n"},{"id":"320738","messageId":"20170525194535.9324-7-avarab@gmail.com","threadId":"46045","inReplyTo":"20170525194535.9324-1-avarab@gmail.com","subject":"[PATCH v4 06/31] grep: add a test asserting that --perl-regexp dies when !PCRE","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2017-05-25T19:45:10Z","receivedAt":"2017-05-25T19:46:36Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"Add a test asserting that when --perl-regexp (and -P for grep) is\ngiven to git-grep & git-log that we die with an error.\n\nIn developing the PCRE v2 series I introduced a regression where -P\nwould (through control-flow fall-through) become synonymous with basic\nPOSIX matching. I.e. 'git grep -P '[\\d]' would match \"d\" instead of\ndigits.\n\nThe entire test suite would still pass with this serious regression,\nsince everything that tested for --perl-regexp would be guarded by the\nPCRE prerequisite, fix that blind-spot by adding tests under !PCRE\nasserting that git must die when given --perl-regexp or -P.\n\nSigned-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n---\n t/t4202-log.sh  |  4 +++-\n t/t7810-grep.sh | 12 ++++++++++++\n 2 files changed, 15 insertions(+), 1 deletion(-)\n\ndiff --git a/t/t4202-log.sh b/t/t4202-log.sh\nindex c25eb9afd1..c44c4337f8 100755\n--- a/t/t4202-log.sh\n+++ b/t/t4202-log.sh\n@@ -418,7 +418,9 @@ test_expect_success 'log with various grep.patternType configurations & command-\n \t\t\tgit log --pretty=tformat:%s --perl-regexp \\\n \t\t\t\t--grep=\"[\\d]\\|\" >actual.perl.long-arg &&\n \t\t\ttest_cmp expect.perl actual.perl.long-arg\n-\n+\t\telse\n+\t\t\ttest_must_fail git log --perl-regexp \\\n+\t\t\t\t--grep=\"[\\d]\\|\"\n \t\tfi &&\n \t\ttest_cmp expect.fixed actual.fixed.long-arg &&\n \t\ttest_cmp expect.basic actual.basic.long-arg &&\ndiff --git a/t/t7810-grep.sh b/t/t7810-grep.sh\nindex c84c4d99f9..8d69113695 100755\n--- a/t/t7810-grep.sh\n+++ b/t/t7810-grep.sh\n@@ -281,6 +281,10 @@ do\n \t\ttest_cmp expected actual\n \t'\n \n+\ttest_expect_success !PCRE \"grep $L with grep.patterntype=perl errors without PCRE\" '\n+\t\ttest_must_fail git -c grep.patterntype=perl grep \"foo.*bar\"\n+\t'\n+\n \ttest_expect_success \"grep $L with grep.patternType=default and grep.extendedRegexp=true\" '\n \t\techo \"${HC}ab:abc\" >expected &&\n \t\tgit \\\n@@ -1058,11 +1062,19 @@ test_expect_success PCRE 'grep --perl-regexp pattern' '\n \ttest_cmp expected actual\n '\n \n+test_expect_success !PCRE 'grep --perl-regexp pattern errors without PCRE' '\n+\ttest_must_fail git grep --perl-regexp \"foo.*bar\"\n+'\n+\n test_expect_success PCRE 'grep -P pattern' '\n \tgit grep -P \"\\p{Ps}.*?\\p{Pe}\" hello.c >actual &&\n \ttest_cmp expected actual\n '\n \n+test_expect_success !PCRE 'grep -P pattern errors without PCRE' '\n+\ttest_must_fail git grep -P \"foo.*bar\"\n+'\n+\n test_expect_success 'grep pattern with grep.extendedRegexp=true' '\n \t>empty &&\n \ttest_must_fail git -c grep.extendedregexp=true \\\n-- \n2.13.0.303.g4ebf302169\n\n"},{"id":"320739","messageId":"20170525194535.9324-10-avarab@gmail.com","threadId":"46045","inReplyTo":"20170525194535.9324-1-avarab@gmail.com","subject":"[PATCH v4 09/31] grep: add tests for --threads=N and grep.threads","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2017-05-25T19:45:13Z","receivedAt":"2017-05-25T19:46:39Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"Add tests for --threads=N being supplied on the command-line, or when\ngrep.threads=N being supplied in the configuration.\n\nWhen the threading support was made run-time configurable in commit\n89f09dd34e (\"grep: add --threads=<num> option and grep.threads\nconfiguration\", 2015-12-15) no tests were added for it.\n\nIn developing a change to the grep code I was able to make\n'--threads=1 <pat>` segfault, while the test suite still passed. This\nchange fixes that blind spot in the tests.\n\nIn addition to asserting that asking for N threads shouldn't segfault,\ntest that the grep output given any N is the same.\n\nThe choice to test only 1..10 as opposed to 1..8 or 1..16 or whatever\nis arbitrary. Testing 1..1024 works locally for me (but gets\nnoticeably slower as more threads are spawned). Given the structure of\nthe code there's no reason to test an arbitrary number of threads,\nonly 0, 1 and >=2 are special modes of operation.\n\nA later patch introduces a PTHREADS test prerequisite which is true\nunder NO_PTHREADS=UnfortunatelyYes, but even under NO_PTHREADS it's\nfine to test --threads=N, we'll just ignore it and not use\nthreading. So these tests also make sense under that mode to assert\nthat --threads=N without pthreads still returns expected results.\n\nSigned-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n---\n t/t7810-grep.sh | 16 ++++++++++++++++\n 1 file changed, 16 insertions(+)\n\ndiff --git a/t/t7810-grep.sh b/t/t7810-grep.sh\nindex daa906b9b0..561709ef6a 100755\n--- a/t/t7810-grep.sh\n+++ b/t/t7810-grep.sh\n@@ -775,6 +775,22 @@ test_expect_success 'grep -W with userdiff' '\n \ttest_cmp expected actual\n '\n \n+for threads in $(test_seq 0 10)\n+do\n+\ttest_expect_success \"grep --threads=$threads & -c grep.threads=$threads\" \"\n+\t\tgit grep --threads=$threads . >actual.$threads &&\n+\t\tif test $threads -ge 1\n+\t\tthen\n+\t\t\ttest_cmp actual.\\$(($threads - 1)) actual.$threads\n+\t\tfi &&\n+\t\tgit -c grep.threads=$threads grep . >actual.$threads &&\n+\t\tif test $threads -ge 1\n+\t\tthen\n+\t\t\ttest_cmp actual.\\$(($threads - 1)) actual.$threads\n+\t\tfi\n+\t\"\n+done\n+\n test_expect_success 'grep from a subdirectory to search wider area (1)' '\n \tmkdir -p s &&\n \t(\n-- \n2.13.0.303.g4ebf302169\n\n"},{"id":"320740","messageId":"20170525194535.9324-11-avarab@gmail.com","threadId":"46045","inReplyTo":"20170525194535.9324-1-avarab@gmail.com","subject":"[PATCH v4 10/31] grep: amend submodule recursion test for regex engine testing","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2017-05-25T19:45:14Z","receivedAt":"2017-05-25T19:46:42Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"Amend the submodule recursion test to prepare it for subsequent tests\nof whether it passes along the grep.patternType to the submodule\ngreps.\n\nThis is the result of searching & replacing:\n\n    foobar -> (1|2)d(3|4)\n    foo    -> (1|2)\n    bar    -> (3|4)\n\nCurrently there's no tests for whether e.g. -P or -E is correctly\npassed along, tests for that will be added in a follow-up change, but\nfirst add content to the tests which will match differently under\ndifferent regex engines.\n\nReuse the pattern established in an earlier commit of mine in this\nseries (\"log: add exhaustive tests for pattern style options &\nconfig\", 2017-04-07). The pattern \"(.|.)[\\d]\" will match this content\ndifferently under fixed/basic/extended & perl.\n\nThis test code was originally added in commit 0281e487fd (\"grep:\noptionally recurse into submodules\", 2016-12-16).\n\nSigned-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n---\n t/t7814-grep-recurse-submodules.sh | 166 ++++++++++++++++++-------------------\n 1 file changed, 83 insertions(+), 83 deletions(-)\n\ndiff --git a/t/t7814-grep-recurse-submodules.sh b/t/t7814-grep-recurse-submodules.sh\nindex 5b6eb3a65e..1472855e1d 100755\n--- a/t/t7814-grep-recurse-submodules.sh\n+++ b/t/t7814-grep-recurse-submodules.sh\n@@ -9,13 +9,13 @@ submodules.\n . ./test-lib.sh\n \n test_expect_success 'setup directory structure and submodule' '\n-\techo \"foobar\" >a &&\n+\techo \"(1|2)d(3|4)\" >a &&\n \tmkdir b &&\n-\techo \"bar\" >b/b &&\n+\techo \"(3|4)\" >b/b &&\n \tgit add a b &&\n \tgit commit -m \"add a and b\" &&\n \tgit init submodule &&\n-\techo \"foobar\" >submodule/a &&\n+\techo \"(1|2)d(3|4)\" >submodule/a &&\n \tgit -C submodule add a &&\n \tgit -C submodule commit -m \"add a\" &&\n \tgit submodule add ./submodule &&\n@@ -24,18 +24,18 @@ test_expect_success 'setup directory structure and submodule' '\n \n test_expect_success 'grep correctly finds patterns in a submodule' '\n \tcat >expect <<-\\EOF &&\n-\ta:foobar\n-\tb/b:bar\n-\tsubmodule/a:foobar\n+\ta:(1|2)d(3|4)\n+\tb/b:(3|4)\n+\tsubmodule/a:(1|2)d(3|4)\n \tEOF\n \n-\tgit grep -e \"bar\" --recurse-submodules >actual &&\n+\tgit grep -e \"(3|4)\" --recurse-submodules >actual &&\n \ttest_cmp expect actual\n '\n \n test_expect_success 'grep and basic pathspecs' '\n \tcat >expect <<-\\EOF &&\n-\tsubmodule/a:foobar\n+\tsubmodule/a:(1|2)d(3|4)\n \tEOF\n \n \tgit grep -e. --recurse-submodules -- submodule >actual &&\n@@ -44,7 +44,7 @@ test_expect_success 'grep and basic pathspecs' '\n \n test_expect_success 'grep and nested submodules' '\n \tgit init submodule/sub &&\n-\techo \"foobar\" >submodule/sub/a &&\n+\techo \"(1|2)d(3|4)\" >submodule/sub/a &&\n \tgit -C submodule/sub add a &&\n \tgit -C submodule/sub commit -m \"add a\" &&\n \tgit -C submodule submodule add ./sub &&\n@@ -54,117 +54,117 @@ test_expect_success 'grep and nested submodules' '\n \tgit commit -m \"updated submodule\" &&\n \n \tcat >expect <<-\\EOF &&\n-\ta:foobar\n-\tb/b:bar\n-\tsubmodule/a:foobar\n-\tsubmodule/sub/a:foobar\n+\ta:(1|2)d(3|4)\n+\tb/b:(3|4)\n+\tsubmodule/a:(1|2)d(3|4)\n+\tsubmodule/sub/a:(1|2)d(3|4)\n \tEOF\n \n-\tgit grep -e \"bar\" --recurse-submodules >actual &&\n+\tgit grep -e \"(3|4)\" --recurse-submodules >actual &&\n \ttest_cmp expect actual\n '\n \n test_expect_success 'grep and multiple patterns' '\n \tcat >expect <<-\\EOF &&\n-\ta:foobar\n-\tsubmodule/a:foobar\n-\tsubmodule/sub/a:foobar\n+\ta:(1|2)d(3|4)\n+\tsubmodule/a:(1|2)d(3|4)\n+\tsubmodule/sub/a:(1|2)d(3|4)\n \tEOF\n \n-\tgit grep -e \"bar\" --and -e \"foo\" --recurse-submodules >actual &&\n+\tgit grep -e \"(3|4)\" --and -e \"(1|2)\" --recurse-submodules >actual &&\n \ttest_cmp expect actual\n '\n \n test_expect_success 'grep and multiple patterns' '\n \tcat >expect <<-\\EOF &&\n-\tb/b:bar\n+\tb/b:(3|4)\n \tEOF\n \n-\tgit grep -e \"bar\" --and --not -e \"foo\" --recurse-submodules >actual &&\n+\tgit grep -e \"(3|4)\" --and --not -e \"(1|2)\" --recurse-submodules >actual &&\n \ttest_cmp expect actual\n '\n \n test_expect_success 'basic grep tree' '\n \tcat >expect <<-\\EOF &&\n-\tHEAD:a:foobar\n-\tHEAD:b/b:bar\n-\tHEAD:submodule/a:foobar\n-\tHEAD:submodule/sub/a:foobar\n+\tHEAD:a:(1|2)d(3|4)\n+\tHEAD:b/b:(3|4)\n+\tHEAD:submodule/a:(1|2)d(3|4)\n+\tHEAD:submodule/sub/a:(1|2)d(3|4)\n \tEOF\n \n-\tgit grep -e \"bar\" --recurse-submodules HEAD >actual &&\n+\tgit grep -e \"(3|4)\" --recurse-submodules HEAD >actual &&\n \ttest_cmp expect actual\n '\n \n test_expect_success 'grep tree HEAD^' '\n \tcat >expect <<-\\EOF &&\n-\tHEAD^:a:foobar\n-\tHEAD^:b/b:bar\n-\tHEAD^:submodule/a:foobar\n+\tHEAD^:a:(1|2)d(3|4)\n+\tHEAD^:b/b:(3|4)\n+\tHEAD^:submodule/a:(1|2)d(3|4)\n \tEOF\n \n-\tgit grep -e \"bar\" --recurse-submodules HEAD^ >actual &&\n+\tgit grep -e \"(3|4)\" --recurse-submodules HEAD^ >actual &&\n \ttest_cmp expect actual\n '\n \n test_expect_success 'grep tree HEAD^^' '\n \tcat >expect <<-\\EOF &&\n-\tHEAD^^:a:foobar\n-\tHEAD^^:b/b:bar\n+\tHEAD^^:a:(1|2)d(3|4)\n+\tHEAD^^:b/b:(3|4)\n \tEOF\n \n-\tgit grep -e \"bar\" --recurse-submodules HEAD^^ >actual &&\n+\tgit grep -e \"(3|4)\" --recurse-submodules HEAD^^ >actual &&\n \ttest_cmp expect actual\n '\n \n test_expect_success 'grep tree and pathspecs' '\n \tcat >expect <<-\\EOF &&\n-\tHEAD:submodule/a:foobar\n-\tHEAD:submodule/sub/a:foobar\n+\tHEAD:submodule/a:(1|2)d(3|4)\n+\tHEAD:submodule/sub/a:(1|2)d(3|4)\n \tEOF\n \n-\tgit grep -e \"bar\" --recurse-submodules HEAD -- submodule >actual &&\n+\tgit grep -e \"(3|4)\" --recurse-submodules HEAD -- submodule >actual &&\n \ttest_cmp expect actual\n '\n \n test_expect_success 'grep tree and pathspecs' '\n \tcat >expect <<-\\EOF &&\n-\tHEAD:submodule/a:foobar\n-\tHEAD:submodule/sub/a:foobar\n+\tHEAD:submodule/a:(1|2)d(3|4)\n+\tHEAD:submodule/sub/a:(1|2)d(3|4)\n \tEOF\n \n-\tgit grep -e \"bar\" --recurse-submodules HEAD -- \"submodule*a\" >actual &&\n+\tgit grep -e \"(3|4)\" --recurse-submodules HEAD -- \"submodule*a\" >actual &&\n \ttest_cmp expect actual\n '\n \n test_expect_success 'grep tree and more pathspecs' '\n \tcat >expect <<-\\EOF &&\n-\tHEAD:submodule/a:foobar\n+\tHEAD:submodule/a:(1|2)d(3|4)\n \tEOF\n \n-\tgit grep -e \"bar\" --recurse-submodules HEAD -- \"submodul?/a\" >actual &&\n+\tgit grep -e \"(3|4)\" --recurse-submodules HEAD -- \"submodul?/a\" >actual &&\n \ttest_cmp expect actual\n '\n \n test_expect_success 'grep tree and more pathspecs' '\n \tcat >expect <<-\\EOF &&\n-\tHEAD:submodule/sub/a:foobar\n+\tHEAD:submodule/sub/a:(1|2)d(3|4)\n \tEOF\n \n-\tgit grep -e \"bar\" --recurse-submodules HEAD -- \"submodul*/sub/a\" >actual &&\n+\tgit grep -e \"(3|4)\" --recurse-submodules HEAD -- \"submodul*/sub/a\" >actual &&\n \ttest_cmp expect actual\n '\n \n test_expect_success !MINGW 'grep recurse submodule colon in name' '\n \tgit init parent &&\n \ttest_when_finished \"rm -rf parent\" &&\n-\techo \"foobar\" >\"parent/fi:le\" &&\n+\techo \"(1|2)d(3|4)\" >\"parent/fi:le\" &&\n \tgit -C parent add \"fi:le\" &&\n \tgit -C parent commit -m \"add fi:le\" &&\n \n \tgit init \"su:b\" &&\n \ttest_when_finished \"rm -rf su:b\" &&\n-\techo \"foobar\" >\"su:b/fi:le\" &&\n+\techo \"(1|2)d(3|4)\" >\"su:b/fi:le\" &&\n \tgit -C \"su:b\" add \"fi:le\" &&\n \tgit -C \"su:b\" commit -m \"add fi:le\" &&\n \n@@ -172,30 +172,30 @@ test_expect_success !MINGW 'grep recurse submodule colon in name' '\n \tgit -C parent commit -m \"add submodule\" &&\n \n \tcat >expect <<-\\EOF &&\n-\tfi:le:foobar\n-\tsu:b/fi:le:foobar\n+\tfi:le:(1|2)d(3|4)\n+\tsu:b/fi:le:(1|2)d(3|4)\n \tEOF\n-\tgit -C parent grep -e \"foobar\" --recurse-submodules >actual &&\n+\tgit -C parent grep -e \"(1|2)d(3|4)\" --recurse-submodules >actual &&\n \ttest_cmp expect actual &&\n \n \tcat >expect <<-\\EOF &&\n-\tHEAD:fi:le:foobar\n-\tHEAD:su:b/fi:le:foobar\n+\tHEAD:fi:le:(1|2)d(3|4)\n+\tHEAD:su:b/fi:le:(1|2)d(3|4)\n \tEOF\n-\tgit -C parent grep -e \"foobar\" --recurse-submodules HEAD >actual &&\n+\tgit -C parent grep -e \"(1|2)d(3|4)\" --recurse-submodules HEAD >actual &&\n \ttest_cmp expect actual\n '\n \n test_expect_success 'grep history with moved submoules' '\n \tgit init parent &&\n \ttest_when_finished \"rm -rf parent\" &&\n-\techo \"foobar\" >parent/file &&\n+\techo \"(1|2)d(3|4)\" >parent/file &&\n \tgit -C parent add file &&\n \tgit -C parent commit -m \"add file\" &&\n \n \tgit init sub &&\n \ttest_when_finished \"rm -rf sub\" &&\n-\techo \"foobar\" >sub/file &&\n+\techo \"(1|2)d(3|4)\" >sub/file &&\n \tgit -C sub add file &&\n \tgit -C sub commit -m \"add file\" &&\n \n@@ -203,82 +203,82 @@ test_expect_success 'grep history with moved submoules' '\n \tgit -C parent commit -m \"add submodule\" &&\n \n \tcat >expect <<-\\EOF &&\n-\tdir/sub/file:foobar\n-\tfile:foobar\n+\tdir/sub/file:(1|2)d(3|4)\n+\tfile:(1|2)d(3|4)\n \tEOF\n-\tgit -C parent grep -e \"foobar\" --recurse-submodules >actual &&\n+\tgit -C parent grep -e \"(1|2)d(3|4)\" --recurse-submodules >actual &&\n \ttest_cmp expect actual &&\n \n \tgit -C parent mv dir/sub sub-moved &&\n \tgit -C parent commit -m \"moved submodule\" &&\n \n \tcat >expect <<-\\EOF &&\n-\tfile:foobar\n-\tsub-moved/file:foobar\n+\tfile:(1|2)d(3|4)\n+\tsub-moved/file:(1|2)d(3|4)\n \tEOF\n-\tgit -C parent grep -e \"foobar\" --recurse-submodules >actual &&\n+\tgit -C parent grep -e \"(1|2)d(3|4)\" --recurse-submodules >actual &&\n \ttest_cmp expect actual &&\n \n \tcat >expect <<-\\EOF &&\n-\tHEAD^:dir/sub/file:foobar\n-\tHEAD^:file:foobar\n+\tHEAD^:dir/sub/file:(1|2)d(3|4)\n+\tHEAD^:file:(1|2)d(3|4)\n \tEOF\n-\tgit -C parent grep -e \"foobar\" --recurse-submodules HEAD^ >actual &&\n+\tgit -C parent grep -e \"(1|2)d(3|4)\" --recurse-submodules HEAD^ >actual &&\n \ttest_cmp expect actual\n '\n \n test_expect_success 'grep using relative path' '\n \ttest_when_finished \"rm -rf parent sub\" &&\n \tgit init sub &&\n-\techo \"foobar\" >sub/file &&\n+\techo \"(1|2)d(3|4)\" >sub/file &&\n \tgit -C sub add file &&\n \tgit -C sub commit -m \"add file\" &&\n \n \tgit init parent &&\n-\techo \"foobar\" >parent/file &&\n+\techo \"(1|2)d(3|4)\" >parent/file &&\n \tgit -C parent add file &&\n \tmkdir parent/src &&\n-\techo \"foobar\" >parent/src/file2 &&\n+\techo \"(1|2)d(3|4)\" >parent/src/file2 &&\n \tgit -C parent add src/file2 &&\n \tgit -C parent submodule add ../sub &&\n \tgit -C parent commit -m \"add files and submodule\" &&\n \n \t# From top works\n \tcat >expect <<-\\EOF &&\n-\tfile:foobar\n-\tsrc/file2:foobar\n-\tsub/file:foobar\n+\tfile:(1|2)d(3|4)\n+\tsrc/file2:(1|2)d(3|4)\n+\tsub/file:(1|2)d(3|4)\n \tEOF\n-\tgit -C parent grep --recurse-submodules -e \"foobar\" >actual &&\n+\tgit -C parent grep --recurse-submodules -e \"(1|2)d(3|4)\" >actual &&\n \ttest_cmp expect actual &&\n \n \t# Relative path to top\n \tcat >expect <<-\\EOF &&\n-\t../file:foobar\n-\tfile2:foobar\n-\t../sub/file:foobar\n+\t../file:(1|2)d(3|4)\n+\tfile2:(1|2)d(3|4)\n+\t../sub/file:(1|2)d(3|4)\n \tEOF\n-\tgit -C parent/src grep --recurse-submodules -e \"foobar\" -- .. >actual &&\n+\tgit -C parent/src grep --recurse-submodules -e \"(1|2)d(3|4)\" -- .. >actual &&\n \ttest_cmp expect actual &&\n \n \t# Relative path to submodule\n \tcat >expect <<-\\EOF &&\n-\t../sub/file:foobar\n+\t../sub/file:(1|2)d(3|4)\n \tEOF\n-\tgit -C parent/src grep --recurse-submodules -e \"foobar\" -- ../sub >actual &&\n+\tgit -C parent/src grep --recurse-submodules -e \"(1|2)d(3|4)\" -- ../sub >actual &&\n \ttest_cmp expect actual\n '\n \n test_expect_success 'grep from a subdir' '\n \ttest_when_finished \"rm -rf parent sub\" &&\n \tgit init sub &&\n-\techo \"foobar\" >sub/file &&\n+\techo \"(1|2)d(3|4)\" >sub/file &&\n \tgit -C sub add file &&\n \tgit -C sub commit -m \"add file\" &&\n \n \tgit init parent &&\n \tmkdir parent/src &&\n-\techo \"foobar\" >parent/src/file &&\n+\techo \"(1|2)d(3|4)\" >parent/src/file &&\n \tgit -C parent add src/file &&\n \tgit -C parent submodule add ../sub src/sub &&\n \tgit -C parent submodule add ../sub sub &&\n@@ -286,19 +286,19 @@ test_expect_success 'grep from a subdir' '\n \n \t# Verify grep from root works\n \tcat >expect <<-\\EOF &&\n-\tsrc/file:foobar\n-\tsrc/sub/file:foobar\n-\tsub/file:foobar\n+\tsrc/file:(1|2)d(3|4)\n+\tsrc/sub/file:(1|2)d(3|4)\n+\tsub/file:(1|2)d(3|4)\n \tEOF\n-\tgit -C parent grep --recurse-submodules -e \"foobar\" >actual &&\n+\tgit -C parent grep --recurse-submodules -e \"(1|2)d(3|4)\" >actual &&\n \ttest_cmp expect actual &&\n \n \t# Verify grep from a subdir works\n \tcat >expect <<-\\EOF &&\n-\tfile:foobar\n-\tsub/file:foobar\n+\tfile:(1|2)d(3|4)\n+\tsub/file:(1|2)d(3|4)\n \tEOF\n-\tgit -C parent/src grep --recurse-submodules -e \"foobar\" >actual &&\n+\tgit -C parent/src grep --recurse-submodules -e \"(1|2)d(3|4)\" >actual &&\n \ttest_cmp expect actual\n '\n \n-- \n2.13.0.303.g4ebf302169\n\n"},{"id":"320741","messageId":"20170525194535.9324-12-avarab@gmail.com","threadId":"46045","inReplyTo":"20170525194535.9324-1-avarab@gmail.com","subject":"[PATCH v4 11/31] grep: add tests for grep pattern types being passed to submodules","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2017-05-25T19:45:15Z","receivedAt":"2017-05-25T19:46:44Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"Add testing for grep pattern types being correctly passed to\nsubmodules. The pattern \"(.|.)[\\d]\" matches differently under\nfixed (not at all), and then matches different lines under\nbasic/extended & perl regular expressions, so this change asserts that\nthe pattern type is passed along correctly.\n\nSigned-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n---\n t/t7814-grep-recurse-submodules.sh | 49 ++++++++++++++++++++++++++++++++++++++\n 1 file changed, 49 insertions(+)\n\ndiff --git a/t/t7814-grep-recurse-submodules.sh b/t/t7814-grep-recurse-submodules.sh\nindex 1472855e1d..3a58197f47 100755\n--- a/t/t7814-grep-recurse-submodules.sh\n+++ b/t/t7814-grep-recurse-submodules.sh\n@@ -313,4 +313,53 @@ test_incompatible_with_recurse_submodules ()\n test_incompatible_with_recurse_submodules --untracked\n test_incompatible_with_recurse_submodules --no-index\n \n+test_expect_success 'grep --recurse-submodules should pass the pattern type along' '\n+\t# Fixed\n+\ttest_must_fail git grep -F --recurse-submodules -e \"(.|.)[\\d]\" &&\n+\ttest_must_fail git -c grep.patternType=fixed grep --recurse-submodules -e \"(.|.)[\\d]\" &&\n+\n+\t# Basic\n+\tgit grep -G --recurse-submodules -e \"(.|.)[\\d]\" >actual &&\n+\tcat >expect <<-\\EOF &&\n+\ta:(1|2)d(3|4)\n+\tsubmodule/a:(1|2)d(3|4)\n+\tsubmodule/sub/a:(1|2)d(3|4)\n+\tEOF\n+\ttest_cmp expect actual &&\n+\tgit -c grep.patternType=basic grep --recurse-submodules -e \"(.|.)[\\d]\" >actual &&\n+\ttest_cmp expect actual &&\n+\n+\t# Extended\n+\tgit grep -E --recurse-submodules -e \"(.|.)[\\d]\" >actual &&\n+\tcat >expect <<-\\EOF &&\n+\t.gitmodules:[submodule \"submodule\"]\n+\t.gitmodules:\tpath = submodule\n+\t.gitmodules:\turl = ./submodule\n+\ta:(1|2)d(3|4)\n+\tsubmodule/.gitmodules:[submodule \"sub\"]\n+\tsubmodule/a:(1|2)d(3|4)\n+\tsubmodule/sub/a:(1|2)d(3|4)\n+\tEOF\n+\ttest_cmp expect actual &&\n+\tgit -c grep.patternType=extended grep --recurse-submodules -e \"(.|.)[\\d]\" >actual &&\n+\ttest_cmp expect actual &&\n+\tgit -c grep.extendedRegexp=true grep --recurse-submodules -e \"(.|.)[\\d]\" >actual &&\n+\ttest_cmp expect actual &&\n+\n+\t# Perl\n+\tif test_have_prereq PCRE\n+\tthen\n+\t\tgit grep -P --recurse-submodules -e \"(.|.)[\\d]\" >actual &&\n+\t\tcat >expect <<-\\EOF &&\n+\t\ta:(1|2)d(3|4)\n+\t\tb/b:(3|4)\n+\t\tsubmodule/a:(1|2)d(3|4)\n+\t\tsubmodule/sub/a:(1|2)d(3|4)\n+\t\tEOF\n+\t\ttest_cmp expect actual &&\n+\t\tgit -c grep.patternType=perl grep --recurse-submodules -e \"(.|.)[\\d]\" >actual &&\n+\t\ttest_cmp expect actual\n+\tfi\n+'\n+\n test_done\n-- \n2.13.0.303.g4ebf302169\n\n"},{"id":"320742","messageId":"20170525194535.9324-13-avarab@gmail.com","threadId":"46045","inReplyTo":"20170525194535.9324-1-avarab@gmail.com","subject":"[PATCH v4 12/31] grep: add a test helper function for less verbose -f \\0 tests","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2017-05-25T19:45:16Z","receivedAt":"2017-05-25T19:46:50Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"Add a helper function to make the tests which check for patterns with\n\\0 in them more succinct. Right now this isn't a big win, but\nsubsequent commits will add a lot more of these tests.\n\nThe helper is based on the match() function in t3070-wildmatch.sh.\n\nSigned-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n---\n t/t7008-grep-binary.sh | 58 +++++++++++++++++++++++++-------------------------\n 1 file changed, 29 insertions(+), 29 deletions(-)\n\ndiff --git a/t/t7008-grep-binary.sh b/t/t7008-grep-binary.sh\nindex 9c9c378119..df93d8e44c 100755\n--- a/t/t7008-grep-binary.sh\n+++ b/t/t7008-grep-binary.sh\n@@ -4,6 +4,29 @@ test_description='git grep in binary files'\n \n . ./test-lib.sh\n \n+nul_match () {\n+\tmatches=$1\n+\tflags=$2\n+\tpattern=$3\n+\tpattern_human=$(echo \"$pattern\" | sed 's/Q/<NUL>/g')\n+\n+\tif test \"$matches\" = 1\n+\tthen\n+\t\ttest_expect_success \"git grep -f f $flags '$pattern_human' a\" \"\n+\t\t\tprintf '$pattern' | q_to_nul >f &&\n+\t\t\tgit grep -f f $flags a\n+\t\t\"\n+\telif test \"$matches\" = 0\n+\tthen\n+\t\ttest_expect_success \"git grep -f f $flags '$pattern_human' a\" \"\n+\t\t\tprintf '$pattern' | q_to_nul >f &&\n+\t\t\ttest_must_fail git grep -f f $flags a\n+\t\t\"\n+\telse\n+\t\ttest_expect_success \"PANIC: Test framework error. Unknown matches value $matches\" 'false'\n+\tfi\n+}\n+\n test_expect_success 'setup' \"\n \techo 'binaryQfile' | q_to_nul >a &&\n \tgit add a &&\n@@ -69,35 +92,12 @@ test_expect_failure 'git grep .fi a' '\n \tgit grep .fi a\n '\n \n-test_expect_success 'git grep -F y<NUL>f a' \"\n-\tprintf 'yQf' | q_to_nul >f &&\n-\tgit grep -f f -F a\n-\"\n-\n-test_expect_success 'git grep -F y<NUL>x a' \"\n-\tprintf 'yQx' | q_to_nul >f &&\n-\ttest_must_fail git grep -f f -F a\n-\"\n-\n-test_expect_success 'git grep -Fi Y<NUL>f a' \"\n-\tprintf 'YQf' | q_to_nul >f &&\n-\tgit grep -f f -Fi a\n-\"\n-\n-test_expect_success 'git grep -Fi Y<NUL>x a' \"\n-\tprintf 'YQx' | q_to_nul >f &&\n-\ttest_must_fail git grep -f f -Fi a\n-\"\n-\n-test_expect_success 'git grep y<NUL>f a' \"\n-\tprintf 'yQf' | q_to_nul >f &&\n-\tgit grep -f f a\n-\"\n-\n-test_expect_success 'git grep y<NUL>x a' \"\n-\tprintf 'yQx' | q_to_nul >f &&\n-\ttest_must_fail git grep -f f a\n-\"\n+nul_match 1 '-F' 'yQf'\n+nul_match 0 '-F' 'yQx'\n+nul_match 1 '-Fi' 'YQf'\n+nul_match 0 '-Fi' 'YQx'\n+nul_match 1 '' 'yQf'\n+nul_match 0 '' 'yQx'\n \n test_expect_success 'grep respects binary diff attribute' '\n \techo text >t &&\n-- \n2.13.0.303.g4ebf302169\n\n"},{"id":"320743","messageId":"20170525194535.9324-14-avarab@gmail.com","threadId":"46045","inReplyTo":"20170525194535.9324-1-avarab@gmail.com","subject":"[PATCH v4 13/31] grep: prepare for testing binary regexes containing rx metacharacters","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2017-05-25T19:45:17Z","receivedAt":"2017-05-25T19:46:59Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"Add setup code needed for testing regexes that contain both binary\ndata and regex metacharacters.\n\nThe POSIX regcomp() function inherently can't support that, because it\ntakes a \\0-delimited char *, but other regex engines APIs like PCRE v2\ntake a pattern/length pair, and are thus able to handle \\0s in\npatterns as well as any other character.\n\nWhen kwset was imported in commit 9eceddeec6 (\"Use kwset in grep\",\n2011-08-21) this limitation was fixed, but at the expense of\nintroducing the undocumented limitation that any pattern containing \\0\nimplicitly becomes a fixed match (equivalent to -F having been\nprovided).\n\nThat's not something we'd like to keep in the future. The inability to\nmatch patterns containing \\0 is a leaky implementation detail.\n\nSo add tests as a first step towards changing that. In order to test\nthat \\0-patterns can properly match as regexes the test string needs\nto have some regex metacharacters in it.\n\nThere were other blind spots in the tests. The code around kwset\nspecially handles case-insensitive & non-ASCII data, but there were no\ntests for this.\n\nFix all of that by amending the text being matched to contain both\nregex metacharacters & non-ASCII data.\n\nSigned-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n---\n t/t7008-grep-binary.sh | 6 +++---\n 1 file changed, 3 insertions(+), 3 deletions(-)\n\ndiff --git a/t/t7008-grep-binary.sh b/t/t7008-grep-binary.sh\nindex df93d8e44c..20370d6e0c 100755\n--- a/t/t7008-grep-binary.sh\n+++ b/t/t7008-grep-binary.sh\n@@ -28,7 +28,7 @@ nul_match () {\n }\n \n test_expect_success 'setup' \"\n-\techo 'binaryQfile' | q_to_nul >a &&\n+\techo 'binaryQfileQm[*]cQ*æQð' | q_to_nul >a &&\n \tgit add a &&\n \tgit commit -m.\n \"\n@@ -162,7 +162,7 @@ test_expect_success 'grep does not honor textconv' '\n '\n \n test_expect_success 'grep --textconv honors textconv' '\n-\techo \"a:binaryQfile\" >expect &&\n+\techo \"a:binaryQfileQm[*]cQ*æQð\" >expect &&\n \tgit grep --textconv Qfile >actual &&\n \ttest_cmp expect actual\n '\n@@ -172,7 +172,7 @@ test_expect_success 'grep --no-textconv does not honor textconv' '\n '\n \n test_expect_success 'grep --textconv blob honors textconv' '\n-\techo \"HEAD:a:binaryQfile\" >expect &&\n+\techo \"HEAD:a:binaryQfileQm[*]cQ*æQð\" >expect &&\n \tgit grep --textconv Qfile HEAD:a >actual &&\n \ttest_cmp expect actual\n '\n-- \n2.13.0.303.g4ebf302169\n\n"},{"id":"320744","messageId":"20170525194535.9324-15-avarab@gmail.com","threadId":"46045","inReplyTo":"20170525194535.9324-1-avarab@gmail.com","subject":"[PATCH v4 14/31] grep: add tests to fix blind spots with \\0 patterns","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2017-05-25T19:45:18Z","receivedAt":"2017-05-25T19:47:04Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"Address a big blind spot in the tests for patterns containing \\0. The\nis_fixed() function considers any string that contains \\0 fixed, even\nif it contains regular expression metacharacters, those patterns are\ncurrently matched with kwset.\n\nBefore this change removing that memchr(s, 0, len) check from\nis_fixed() wouldn't change the result of any of the tests, since\nregcomp() will happily match the part before the \\0.\n\nThe kwset path is dependent on whether the the -i flag is on, and\nwhether the pattern has any non-ASCII characters, but none of this was\ntested for.\n\nSigned-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n---\n t/t7008-grep-binary.sh | 71 ++++++++++++++++++++++++++++++++++++++++++++++++++\n 1 file changed, 71 insertions(+)\n\ndiff --git a/t/t7008-grep-binary.sh b/t/t7008-grep-binary.sh\nindex 20370d6e0c..615e7e0162 100755\n--- a/t/t7008-grep-binary.sh\n+++ b/t/t7008-grep-binary.sh\n@@ -22,6 +22,18 @@ nul_match () {\n \t\t\tprintf '$pattern' | q_to_nul >f &&\n \t\t\ttest_must_fail git grep -f f $flags a\n \t\t\"\n+\telif test \"$matches\" = T1\n+\tthen\n+\t\ttest_expect_failure \"git grep -f f $flags '$pattern_human' a\" \"\n+\t\t\tprintf '$pattern' | q_to_nul >f &&\n+\t\t\tgit grep -f f $flags a\n+\t\t\"\n+\telif test \"$matches\" = T0\n+\tthen\n+\t\ttest_expect_failure \"git grep -f f $flags '$pattern_human' a\" \"\n+\t\t\tprintf '$pattern' | q_to_nul >f &&\n+\t\t\ttest_must_fail git grep -f f $flags a\n+\t\t\"\n \telse\n \t\ttest_expect_success \"PANIC: Test framework error. Unknown matches value $matches\" 'false'\n \tfi\n@@ -98,6 +110,65 @@ nul_match 1 '-Fi' 'YQf'\n nul_match 0 '-Fi' 'YQx'\n nul_match 1 '' 'yQf'\n nul_match 0 '' 'yQx'\n+nul_match 1 '' 'æQð'\n+nul_match 1 '-F' 'eQm[*]c'\n+nul_match 1 '-Fi' 'EQM[*]C'\n+\n+# Regex patterns that would match but shouldn't with -F\n+nul_match 0 '-F' 'yQ[f]'\n+nul_match 0 '-F' '[y]Qf'\n+nul_match 0 '-Fi' 'YQ[F]'\n+nul_match 0 '-Fi' '[Y]QF'\n+nul_match 0 '-F' 'æQ[ð]'\n+nul_match 0 '-F' '[æ]Qð'\n+nul_match 0 '-Fi' 'ÆQ[Ð]'\n+nul_match 0 '-Fi' '[Æ]QÐ'\n+\n+# kwset is disabled on -i & non-ASCII. No way to match non-ASCII \\0\n+# patterns case-insensitively.\n+nul_match T1 '-i' 'ÆQÐ'\n+\n+# \\0 implicitly disables regexes. This is an undocumented internal\n+# limitation.\n+nul_match T1 '' 'yQ[f]'\n+nul_match T1 '' '[y]Qf'\n+nul_match T1 '-i' 'YQ[F]'\n+nul_match T1 '-i' '[Y]Qf'\n+nul_match T1 '' 'æQ[ð]'\n+nul_match T1 '' '[æ]Qð'\n+nul_match T1 '-i' 'ÆQ[Ð]'\n+\n+# ... because of \\0 implicitly disabling regexes regexes that\n+# should/shouldn't match don't do the right thing.\n+nul_match T1 '' 'eQm.*cQ'\n+nul_match T1 '-i' 'EQM.*cQ'\n+nul_match T0 '' 'eQm[*]c'\n+nul_match T0 '-i' 'EQM[*]C'\n+\n+# Due to the REG_STARTEND extension when kwset() is disabled on -i &\n+# non-ASCII the string will be matched in its entirety, but the\n+# pattern will be cut off at the first \\0.\n+nul_match 0 '-i' 'NOMATCHQð'\n+nul_match T0 '-i' '[Æ]QNOMATCH'\n+nul_match T0 '-i' '[æ]QNOMATCH'\n+# Matches, but for the wrong reasons, just stops at [æ]\n+nul_match 1 '-i' '[Æ]Qð'\n+nul_match 1 '-i' '[æ]Qð'\n+\n+# Ensure that the matcher doesn't regress to something that stops at\n+# \\0\n+nul_match 0 '-F' 'yQ[f]'\n+nul_match 0 '-Fi' 'YQ[F]'\n+nul_match 0 '' 'yQNOMATCH'\n+nul_match 0 '' 'QNOMATCH'\n+nul_match 0 '-i' 'YQNOMATCH'\n+nul_match 0 '-i' 'QNOMATCH'\n+nul_match 0 '-F' 'æQ[ð]'\n+nul_match 0 '-Fi' 'ÆQ[Ð]'\n+nul_match 0 '' 'yQNÓMATCH'\n+nul_match 0 '' 'QNÓMATCH'\n+nul_match 0 '-i' 'YQNÓMATCH'\n+nul_match 0 '-i' 'QNÓMATCH'\n \n test_expect_success 'grep respects binary diff attribute' '\n \techo text >t &&\n-- \n2.13.0.303.g4ebf302169\n\n"},{"id":"320745","messageId":"20170525194535.9324-17-avarab@gmail.com","threadId":"46045","inReplyTo":"20170525194535.9324-1-avarab@gmail.com","subject":"[PATCH v4 16/31] perf: emit progress output when unpacking & building","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2017-05-25T19:45:20Z","receivedAt":"2017-05-25T19:47:10Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"Amend the t/perf/run output so that in addition to the \"Running N\ntests\" heading currently being emitted, it also emits \"Unpacking $rev\"\nand \"Building $rev\" when setting up the build/$rev directory & when\nbuilding it, respectively.\n\nThis makes it easier to see what's going on and what revision is being\ntested as the output scrolls by.\n\nSigned-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n---\n t/perf/run | 2 ++\n 1 file changed, 2 insertions(+)\n\ndiff --git a/t/perf/run b/t/perf/run\nindex b61024a830..beb4acc0e4 100755\n--- a/t/perf/run\n+++ b/t/perf/run\n@@ -24,6 +24,7 @@ run_one_dir () {\n \n unpack_git_rev () {\n \trev=$1\n+\techo \"=== Unpacking $rev in build/$rev ===\"\n \tmkdir -p build/$rev\n \t(cd \"$(git rev-parse --show-cdup)\" && git archive --format=tar $rev) |\n \t(cd build/$rev && tar x)\n@@ -37,6 +38,7 @@ build_git_rev () {\n \t\t\tcp \"../../$config\" \"build/$rev/\"\n \t\tfi\n \tdone\n+\techo \"=== Building $rev ===\"\n \t(\n \t\tcd build/$rev &&\n \t\tif test -n \"$GIT_PERF_MAKE_COMMAND\"\n-- \n2.13.0.303.g4ebf302169\n\n"},{"id":"320746","messageId":"20170525194535.9324-19-avarab@gmail.com","threadId":"46045","inReplyTo":"20170525194535.9324-1-avarab@gmail.com","subject":"[PATCH v4 18/31] perf: add a comparison test of grep regex engines with -F","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2017-05-25T19:45:22Z","receivedAt":"2017-05-25T19:47:12Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"Add a performance comparison test of grep regex engines given fixed\nstrings.\n\nThe current logic in compile_regexp() ignores the engine parameter and\nuses kwset() to search for these, so this test shows no difference\nbetween engines right now:\n\n    $ GIT_PERF_REPEAT_COUNT=10 GIT_PERF_LARGE_REPO=~/g/linux ./run p7821-grep-engines-fixed.sh\n    [...]\n    Test                             this tree\n    ------------------------------------------------\n    7821.1: fixed grep int           0.56(1.67+0.68)\n    7821.2: basic grep int           0.57(1.70+0.57)\n    7821.3: extended grep int        0.59(1.76+0.51)\n    7821.4: perl grep int            1.08(1.71+0.55)\n    7821.6: fixed grep uncommon      0.23(0.55+0.50)\n    7821.7: basic grep uncommon      0.24(0.55+0.50)\n    7821.8: extended grep uncommon   0.26(0.55+0.52)\n    7821.9: perl grep uncommon       0.24(0.58+0.47)\n    7821.11: fixed grep æ            0.36(1.30+0.42)\n    7821.12: basic grep æ            0.36(1.32+0.40)\n    7821.13: extended grep æ         0.38(1.30+0.42)\n    7821.14: perl grep æ             0.35(1.24+0.48)\n\nOnly when run with -i via GIT_PERF_7821_GREP_OPTS=' -i' do we avoid\navoid going through the same kwset.[ch] codepath, see the \"Even when\n-F...\"  comment in grep.c. This only kicks for the non-ASCII case:\n\n    $ GIT_PERF_REPEAT_COUNT=10 GIT_PERF_LARGE_REPO=~/g/linux GIT_PERF_7821_GREP_OPTS=' -i' ./run p7821-grep-engines-fixed.sh\n    [...]\n    Test                                this tree\n    ---------------------------------------------------\n    7821.1: fixed grep -i int           0.62(2.10+0.57)\n    7821.2: basic grep -i int           0.68(1.90+0.61)\n    7821.3: extended grep -i int        0.78(1.94+0.57)\n    7821.4: perl grep -i int            0.98(1.78+0.74)\n    7821.6: fixed grep -i uncommon      0.24(0.44+0.64)\n    7821.7: basic grep -i uncommon      0.25(0.56+0.54)\n    7821.8: extended grep -i uncommon   0.27(0.62+0.45)\n    7821.9: perl grep -i uncommon       0.24(0.59+0.49)\n    7821.11: fixed grep -i æ            0.30(0.96+0.39)\n    7821.12: basic grep -i æ            0.27(0.92+0.44)\n    7821.13: extended grep -i æ         0.28(0.90+0.46)\n    7821.14: perl grep -i æ             0.28(0.74+0.49)\n\nI'm planning to change how fixed-string searching happens. This test\ngives a baseline for comparing performance before & after any such\nchange.\n\nSee commit (\"perf: add a comparison test of grep regex engines\",\n2017-04-19) for details on the machine the above test run was executed\non.\n\nSigned-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n---\n t/perf/p7821-grep-engines-fixed.sh | 41 ++++++++++++++++++++++++++++++++++++++\n 1 file changed, 41 insertions(+)\n create mode 100755 t/perf/p7821-grep-engines-fixed.sh\n\ndiff --git a/t/perf/p7821-grep-engines-fixed.sh b/t/perf/p7821-grep-engines-fixed.sh\nnew file mode 100755\nindex 0000000000..c7ef1e198f\n--- /dev/null\n+++ b/t/perf/p7821-grep-engines-fixed.sh\n@@ -0,0 +1,41 @@\n+#!/bin/sh\n+\n+test_description=\"Comparison of git-grep's regex engines with -F\n+\n+Set GIT_PERF_7821_GREP_OPTS in the environment to pass options to\n+git-grep. Make sure to include a leading space,\n+e.g. GIT_PERF_7821_GREP_OPTS=' -w'. See p7820-grep-engines.sh for more\n+options to try.\n+\"\n+\n+. ./perf-lib.sh\n+\n+test_perf_large_repo\n+test_checkout_worktree\n+\n+for pattern in 'int' 'uncommon' 'æ'\n+do\n+\tfor engine in fixed basic extended perl\n+\tdo\n+\t\tif test $engine = \"perl\" && ! test_have_prereq PCRE\n+\t\tthen\n+\t\t\tprereq=\"PCRE\"\n+\t\telse\n+\t\t\tprereq=\"\"\n+\t\tfi\n+\t\ttest_perf $prereq \"$engine grep$GIT_PERF_7821_GREP_OPTS $pattern\" \"\n+\t\t\tgit -c grep.patternType=$engine grep$GIT_PERF_7821_GREP_OPTS $pattern >'out.$engine' || :\n+\t\t\"\n+\tdone\n+\n+\ttest_expect_success \"assert that all engines found the same for$GIT_PERF_7821_GREP_OPTS $pattern\" '\n+\t\ttest_cmp out.fixed out.basic &&\n+\t\ttest_cmp out.fixed out.extended &&\n+\t\tif test_have_prereq PCRE\n+\t\tthen\n+\t\t\ttest_cmp out.fixed out.perl\n+\t\tfi\n+\t'\n+done\n+\n+test_done\n-- \n2.13.0.303.g4ebf302169\n\n"},{"id":"320747","messageId":"20170525194535.9324-18-avarab@gmail.com","threadId":"46045","inReplyTo":"20170525194535.9324-1-avarab@gmail.com","subject":"[PATCH v4 17/31] perf: add a comparison test of grep regex engines","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2017-05-25T19:45:21Z","receivedAt":"2017-05-25T19:47:19Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"Add a very basic performance comparison test comparing the POSIX\nbasic, extended and perl engines.\n\nIn theory the \"basic\" and \"extended\" engines should be implemented\nusing the same underlying code with a slightly different pattern\nparser, but some implementations may not do this. Jump through some\nslight hoops to test both, which is worthwhile since \"basic\" is the\ndefault.\n\nRunning this on an i7 3.4GHz Linux 4.9.0-2 Debian testing against a\ncheckout of linux.git & latest upstream PCRE, both PCRE and git\ncompiled with -O3 using gcc 7.1.1:\n\n    $ GIT_PERF_REPEAT_COUNT=10 GIT_PERF_LARGE_REPO=~/g/linux ./run p7820-grep-engines.sh\n    [...]\n    Test                                            this tree\n    ---------------------------------------------------------------\n    7820.1: basic grep 'how.to'                     0.34(1.24+0.53)\n    7820.2: extended grep 'how.to'                  0.33(1.23+0.45)\n    7820.3: perl grep 'how.to'                      0.31(1.05+0.56)\n    7820.5: basic grep '^how to'                    0.32(1.24+0.42)\n    7820.6: extended grep '^how to'                 0.33(1.20+0.44)\n    7820.7: perl grep '^how to'                     0.57(2.67+0.42)\n    7820.9: basic grep '[how] to'                   0.51(2.16+0.45)\n    7820.10: extended grep '[how] to'               0.49(2.20+0.43)\n    7820.11: perl grep '[how] to'                   0.56(2.60+0.43)\n    7820.13: basic grep '\\(e.t[^ ]*\\|v.ry\\) rare'   0.66(3.25+0.40)\n    7820.14: extended grep '(e.t[^ ]*|v.ry) rare'   0.65(3.19+0.46)\n    7820.15: perl grep '(e.t[^ ]*|v.ry) rare'       1.05(5.74+0.34)\n    7820.17: basic grep 'm\\(ú\\|u\\)lt.b\\(æ\\|y\\)te'   0.34(1.28+0.47)\n    7820.18: extended grep 'm(ú|u)lt.b(æ|y)te'      0.34(1.38+0.38)\n    7820.19: perl grep 'm(ú|u)lt.b(æ|y)te'          0.39(1.56+0.44)\n\nOptions can also be passed to git-grep via the GIT_PERF_7820_GREP_OPTS\nenvironment variable. There are various modes such as \"-v\" that have\nvery different performance profiles, but handling the combinatorial\nexplosion of testing all those options would make this script much\nmore complex and harder to maintain. Instead just add the ability to\ndo one-shot runs with arbitrary options, e.g.:\n\n    $ GIT_PERF_REPEAT_COUNT=10 GIT_PERF_LARGE_REPO=~/g/linux GIT_PERF_7820_GREP_OPTS=\" -i\" ./run p7820-grep-engines.sh\n    [...]\n    Test                                               this tree\n    ------------------------------------------------------------------\n    7820.1: basic grep -i 'how.to'                     0.49(1.72+0.38)\n    7820.2: extended grep -i 'how.to'                  0.46(1.64+0.42)\n    7820.3: perl grep -i 'how.to'                      0.44(1.45+0.45)\n    7820.5: basic grep -i '^how to'                    0.47(1.76+0.38)\n    7820.6: extended grep -i '^how to'                 0.47(1.70+0.42)\n    7820.7: perl grep -i '^how to'                     0.65(2.72+0.37)\n    7820.9: basic grep -i '[how] to'                   0.86(3.64+0.42)\n    7820.10: extended grep -i '[how] to'               0.84(3.62+0.46)\n    7820.11: perl grep -i '[how] to'                   0.73(3.06+0.39)\n    7820.13: basic grep -i '\\(e.t[^ ]*\\|v.ry\\) rare'   1.63(8.13+0.36)\n    7820.14: extended grep -i '(e.t[^ ]*|v.ry) rare'   1.64(8.01+0.44)\n    7820.15: perl grep -i '(e.t[^ ]*|v.ry) rare'       1.44(6.88+0.44)\n    7820.17: basic grep -i 'm\\(ú\\|u\\)lt.b\\(æ\\|y\\)te'   0.66(2.67+0.44)\n    7820.18: extended grep -i 'm(ú|u)lt.b(æ|y)te'      0.66(2.67+0.43)\n    7820.19: perl grep -i 'm(ú|u)lt.b(æ|y)te'          0.59(2.31+0.37)\n\nSigned-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n---\n t/perf/p7820-grep-engines.sh | 56 ++++++++++++++++++++++++++++++++++++++++++++\n 1 file changed, 56 insertions(+)\n create mode 100755 t/perf/p7820-grep-engines.sh\n\ndiff --git a/t/perf/p7820-grep-engines.sh b/t/perf/p7820-grep-engines.sh\nnew file mode 100755\nindex 0000000000..62aba19e76\n--- /dev/null\n+++ b/t/perf/p7820-grep-engines.sh\n@@ -0,0 +1,56 @@\n+#!/bin/sh\n+\n+test_description=\"Comparison of git-grep's regex engines\n+\n+Set GIT_PERF_7820_GREP_OPTS in the environment to pass options to\n+git-grep. Make sure to include a leading space,\n+e.g. GIT_PERF_7820_GREP_OPTS=' -i'. Some options to try:\n+\n+\t-i\n+\t-w\n+\t-v\n+\t-vi\n+\t-vw\n+\t-viw\n+\"\n+\n+. ./perf-lib.sh\n+\n+test_perf_large_repo\n+test_checkout_worktree\n+\n+for pattern in \\\n+\t'how.to' \\\n+\t'^how to' \\\n+\t'[how] to' \\\n+\t'\\(e.t[^ ]*\\|v.ry\\) rare' \\\n+\t'm\\(ú\\|u\\)lt.b\\(æ\\|y\\)te'\n+do\n+\tfor engine in basic extended perl\n+\tdo\n+\t\tif test $engine != \"basic\"\n+\t\tthen\n+\t\t\t# Poor man's basic -> extended converter.\n+\t\t\tpattern=$(echo \"$pattern\" | sed 's/\\\\//g')\n+\t\tfi\n+\t\tif test $engine = \"perl\" && ! test_have_prereq PCRE\n+\t\tthen\n+\t\t\tprereq=\"PCRE\"\n+\t\telse\n+\t\t\tprereq=\"\"\n+\t\tfi\n+\t\ttest_perf $prereq \"$engine grep$GIT_PERF_7820_GREP_OPTS '$pattern'\" \"\n+\t\t\tgit -c grep.patternType=$engine grep$GIT_PERF_7820_GREP_OPTS -- '$pattern' >'out.$engine' || :\n+\t\t\"\n+\tdone\n+\n+\ttest_expect_success \"assert that all engines found the same for$GIT_PERF_7820_GREP_OPTS '$pattern'\" '\n+\t\ttest_cmp out.basic out.extended &&\n+\t\tif test_have_prereq PCRE\n+\t\tthen\n+\t\t\ttest_cmp out.basic out.perl\n+\t\tfi\n+\t'\n+done\n+\n+test_done\n-- \n2.13.0.303.g4ebf302169\n\n"},{"id":"320748","messageId":"20170525194535.9324-16-avarab@gmail.com","threadId":"46045","inReplyTo":"20170525194535.9324-1-avarab@gmail.com","subject":"[PATCH v4 15/31] perf: add a GIT_PERF_MAKE_COMMAND for when *_MAKE_OPTS won't do","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2017-05-25T19:45:19Z","receivedAt":"2017-05-25T19:47:22Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"Add a git GIT_PERF_MAKE_COMMAND variable to compliment the existing\nGIT_PERF_MAKE_OPTS facility. This allows specifying an arbitrary shell\ncommand to execute instead of 'make'.\n\nThis is useful e.g. in cases where the name, semantics or defaults of\na Makefile flag have changed over time. It can even be used to change\nthe contents of the tree, useful for monkeypatching ancient versions\nof git to get them to build.\n\nThis opens Pandora's box in some ways, it's now possible to\n\"jailbreak\" the perf environment and e.g. modify the source tree via\nthis arbitrary instead of just issuing a custom \"make\" command, such a\ncommand has to be re-entrant in the sense that subsequent perf runs\nwill re-use the possibly modified tree.\n\nIt would be pointless to try to mitigate or work around that caveat in\na tool purely aimed at Git developers, so this change makes no attempt\nto do so.\n\nSigned-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n---\n Makefile      |  3 +++\n t/perf/README | 17 ++++++++++++++++-\n t/perf/run    | 11 +++++++++--\n 3 files changed, 28 insertions(+), 3 deletions(-)\n\ndiff --git a/Makefile b/Makefile\nindex eedadb8056..d1587452f1 100644\n--- a/Makefile\n+++ b/Makefile\n@@ -2272,6 +2272,9 @@ endif\n ifdef GIT_PERF_MAKE_OPTS\n \t@echo GIT_PERF_MAKE_OPTS=\\''$(subst ','\\'',$(subst ','\\'',$(GIT_PERF_MAKE_OPTS)))'\\' >>$@+\n endif\n+ifdef GIT_PERF_MAKE_COMMAND\n+\t@echo GIT_PERF_MAKE_COMMAND=\\''$(subst ','\\'',$(subst ','\\'',$(GIT_PERF_MAKE_COMMAND)))'\\' >>$@+\n+endif\n ifdef GIT_INTEROP_MAKE_OPTS\n \t@echo GIT_INTEROP_MAKE_OPTS=\\''$(subst ','\\'',$(subst ','\\'',$(GIT_INTEROP_MAKE_OPTS)))'\\' >>$@+\n endif\ndiff --git a/t/perf/README b/t/perf/README\nindex 49ea4349be..0b6a8d2906 100644\n--- a/t/perf/README\n+++ b/t/perf/README\n@@ -60,7 +60,22 @@ You can set the following variables (also in your config.mak):\n \n     GIT_PERF_MAKE_OPTS\n \tOptions to use when automatically building a git tree for\n-\tperformance testing.  E.g., -j6 would be useful.\n+\tperformance testing. E.g., -j6 would be useful. Passed\n+\tdirectly to make as \"make $GIT_PERF_MAKE_OPTS\".\n+\n+    GIT_PERF_MAKE_COMMAND\n+\tAn arbitrary command that'll be run in place of the make\n+\tcommand, if set the GIT_PERF_MAKE_OPTS variable is\n+\tignored. Useful in cases where source tree changes might\n+\trequire issuing a different make command to different\n+\trevisions.\n+\n+\tThis can be (ab)used to monkeypatch or otherwise change the\n+\ttree about to be built. Note that the build directory can be\n+\tre-used for subsequent runs so the make command might get\n+\texecuted multiple times on the same tree, but don't count on\n+\tany of that, that's an implementation detail that might change\n+\tin the future.\n \n     GIT_PERF_REPO\n     GIT_PERF_LARGE_REPO\ndiff --git a/t/perf/run b/t/perf/run\nindex c788d713ae..b61024a830 100755\n--- a/t/perf/run\n+++ b/t/perf/run\n@@ -37,8 +37,15 @@ build_git_rev () {\n \t\t\tcp \"../../$config\" \"build/$rev/\"\n \t\tfi\n \tdone\n-\t(cd build/$rev && make $GIT_PERF_MAKE_OPTS) ||\n-\tdie \"failed to build revision '$mydir'\"\n+\t(\n+\t\tcd build/$rev &&\n+\t\tif test -n \"$GIT_PERF_MAKE_COMMAND\"\n+\t\tthen\n+\t\t\tsh -c \"$GIT_PERF_MAKE_COMMAND\"\n+\t\telse\n+\t\t\tmake $GIT_PERF_MAKE_OPTS\n+\t\tfi\n+\t) || die \"failed to build revision '$mydir'\"\n }\n \n run_dirs_helper () {\n-- \n2.13.0.303.g4ebf302169\n\n"},{"id":"320749","messageId":"20170525194535.9324-20-avarab@gmail.com","threadId":"46045","inReplyTo":"20170525194535.9324-1-avarab@gmail.com","subject":"[PATCH v4 19/31] perf: add a comparison test of log --grep regex engines","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2017-05-25T19:45:23Z","receivedAt":"2017-05-25T19:47:24Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"Add a very basic performance comparison test comparing the POSIX\nbasic, extended and perl engines with patterns matching log messages\nvia --grep=<pattern>.\n\n    $ GIT_PERF_REPEAT_COUNT=10 GIT_PERF_LARGE_REPO=~/g/linux ./run p4220-log-grep-engines.sh\n    [...]\n    Test                                                  this tree\n    ---------------------------------------------------------------------\n    4220.1: basic log --grep='how.to'                     6.22(6.00+0.21)\n    4220.2: extended log --grep='how.to'                  6.23(5.98+0.23)\n    4220.3: perl log --grep='how.to'                      6.07(5.79+0.25)\n    4220.5: basic log --grep='^how to'                    6.19(5.93+0.22)\n    4220.6: extended log --grep='^how to'                 6.19(5.93+0.23)\n    4220.7: perl log --grep='^how to'                     6.14(5.88+0.24)\n    4220.9: basic log --grep='[how] to'                   6.96(6.65+0.28)\n    4220.10: extended log --grep='[how] to'               6.96(6.69+0.24)\n    4220.11: perl log --grep='[how] to'                   6.95(6.58+0.33)\n    4220.13: basic log --grep='\\(e.t[^ ]*\\|v.ry\\) rare'   7.10(6.80+0.27)\n    4220.14: extended log --grep='(e.t[^ ]*|v.ry) rare'   7.07(6.80+0.26)\n    4220.15: perl log --grep='(e.t[^ ]*|v.ry) rare'       7.70(7.46+0.22)\n    4220.17: basic log --grep='m\\(ú\\|u\\)lt.b\\(æ\\|y\\)te'   6.12(5.87+0.24)\n    4220.18: extended log --grep='m(ú|u)lt.b(æ|y)te'      6.14(5.84+0.26)\n    4220.19: perl log --grep='m(ú|u)lt.b(æ|y)te'          6.16(5.93+0.20)\n\nWith -i:\n\n    $ GIT_PERF_REPEAT_COUNT=10 GIT_PERF_LARGE_REPO=~/g/linux GIT_PERF_4220_LOG_OPTS=' -i' ./run p4220-log-grep-engines.sh\n    [...]\n    Test                                                     this tree\n    ------------------------------------------------------------------------\n    4220.1: basic log -i --grep='how.to'                     6.74(6.41+0.32)\n    4220.2: extended log -i --grep='how.to'                  6.78(6.55+0.22)\n    4220.3: perl log -i --grep='how.to'                      6.06(5.77+0.28)\n    4220.5: basic log -i --grep='^how to'                    6.80(6.57+0.22)\n    4220.6: extended log -i --grep='^how to'                 6.83(6.52+0.29)\n    4220.7: perl log -i --grep='^how to'                     6.16(5.94+0.20)\n    4220.9: basic log -i --grep='[how] to'                   7.87(7.61+0.24)\n    4220.10: extended log -i --grep='[how] to'               7.85(7.57+0.27)\n    4220.11: perl log -i --grep='[how] to'                   7.03(6.75+0.25)\n    4220.13: basic log -i --grep='\\(e.t[^ ]*\\|v.ry\\) rare'   8.68(8.41+0.25)\n    4220.14: extended log -i --grep='(e.t[^ ]*|v.ry) rare'   8.80(8.44+0.28)\n    4220.15: perl log -i --grep='(e.t[^ ]*|v.ry) rare'       7.85(7.56+0.26)\n    4220.17: basic log -i --grep='m\\(ú\\|u\\)lt.b\\(æ\\|y\\)te'   6.94(6.68+0.24)\n    4220.18: extended log -i --grep='m(ú|u)lt.b(æ|y)te'      7.04(6.76+0.24)\n    4220.19: perl log -i --grep='m(ú|u)lt.b(æ|y)te'          6.26(5.92+0.29)\n\nSee commit (\"perf: add a comparison test of grep regex engines\",\n2017-04-19) for details on the machine the above test run was executed\non.\n\nBefore commit (\"log: make --regexp-ignore-case work with\n--perl-regexp\", 2017-05-20) this test will almost definitely\nfail (depending on the repo) if passed the -i option, since it wasn't\nproperly supported under PCRE.\n\nSigned-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n---\n t/perf/p4220-log-grep-engines.sh | 53 ++++++++++++++++++++++++++++++++++++++++\n 1 file changed, 53 insertions(+)\n create mode 100755 t/perf/p4220-log-grep-engines.sh\n\ndiff --git a/t/perf/p4220-log-grep-engines.sh b/t/perf/p4220-log-grep-engines.sh\nnew file mode 100755\nindex 0000000000..2bc47ded4d\n--- /dev/null\n+++ b/t/perf/p4220-log-grep-engines.sh\n@@ -0,0 +1,53 @@\n+#!/bin/sh\n+\n+test_description=\"Comparison of git-log's --grep regex engines\n+\n+Set GIT_PERF_4220_LOG_OPTS in the environment to pass options to\n+git-grep. Make sure to include a leading space,\n+e.g. GIT_PERF_4220_LOG_OPTS=' -i'. Some options to try:\n+\n+\t-i\n+\t--invert-grep\n+\t-i --invert-grep\n+\"\n+\n+. ./perf-lib.sh\n+\n+test_perf_large_repo\n+test_checkout_worktree\n+\n+for pattern in \\\n+\t'how.to' \\\n+\t'^how to' \\\n+\t'[how] to' \\\n+\t'\\(e.t[^ ]*\\|v.ry\\) rare' \\\n+\t'm\\(ú\\|u\\)lt.b\\(æ\\|y\\)te'\n+do\n+\tfor engine in basic extended perl\n+\tdo\n+\t\tif test $engine != \"basic\"\n+\t\tthen\n+\t\t\t# Poor man's basic -> extended converter.\n+\t\t\tpattern=$(echo $pattern | sed 's/\\\\//g')\n+\t\tfi\n+\t\tif test $engine = \"perl\" && ! test_have_prereq PCRE\n+\t\tthen\n+\t\t\tprereq=\"PCRE\"\n+\t\telse\n+\t\t\tprereq=\"\"\n+\t\tfi\n+\t\ttest_perf $prereq \"$engine log$GIT_PERF_4220_LOG_OPTS --grep='$pattern'\" \"\n+\t\t\tgit -c grep.patternType=$engine log --pretty=format:%h$GIT_PERF_4220_LOG_OPTS --grep='$pattern' >'out.$engine' || :\n+\t\t\"\n+\tdone\n+\n+\ttest_expect_success \"assert that all engines found the same for$GIT_PERF_4220_LOG_OPTS '$pattern'\" '\n+\t\ttest_cmp out.basic out.extended &&\n+\t\tif test_have_prereq PCRE\n+\t\tthen\n+\t\t\ttest_cmp out.basic out.perl\n+\t\tfi\n+\t'\n+done\n+\n+test_done\n-- \n2.13.0.303.g4ebf302169\n\n"},{"id":"320750","messageId":"20170525194535.9324-21-avarab@gmail.com","threadId":"46045","inReplyTo":"20170525194535.9324-1-avarab@gmail.com","subject":"[PATCH v4 20/31] perf: add a comparison test of log --grep regex engines with -F","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2017-05-25T19:45:24Z","receivedAt":"2017-05-25T19:47:27Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"Add a performance comparison test of log --grepgrep regex engines\ngiven fixed strings.\n\nSee the preceding fixed-string t/perf change (\"perf: add a comparison\ntest of grep regex engines with -F\", 2017-04-21) for notes about this,\nin particular this mostly tests exactly the same codepath now, but\nmight not in the future:\n\n    $ GIT_PERF_REPEAT_COUNT=10 GIT_PERF_LARGE_REPO=~/g/linux ./run p4221-log-grep-engines-fixed.sh\n    [...]\n    Test                                     this tree\n    --------------------------------------------------------\n    4221.1: fixed log --grep='int'           5.99(5.55+0.40)\n    4221.2: basic log --grep='int'           5.92(5.56+0.31)\n    4221.3: extended log --grep='int'        6.01(5.51+0.45)\n    4221.4: perl log --grep='int'            5.99(5.56+0.38)\n    4221.6: fixed log --grep='uncommon'      5.06(4.76+0.27)\n    4221.7: basic log --grep='uncommon'      5.02(4.78+0.21)\n    4221.8: extended log --grep='uncommon'   4.99(4.78+0.20)\n    4221.9: perl log --grep='uncommon'       5.00(4.72+0.26)\n    4221.11: fixed log --grep='æ'            5.35(5.12+0.20)\n    4221.12: basic log --grep='æ'            5.34(5.11+0.20)\n    4221.13: extended log --grep='æ'         5.39(5.10+0.22)\n    4221.14: perl log --grep='æ'             5.44(5.16+0.23)\n\nOnly the non-ASCII -i case is different:\n\n    $ GIT_PERF_REPEAT_COUNT=10 GIT_PERF_LARGE_REPO=~/g/linux GIT_PERF_4221_LOG_OPTS=' -i' ./run p4221-log-grep-engines-fixed.sh\n    [...]\n    Test                                        this tree\n    -----------------------------------------------------------\n    4221.1: fixed log -i --grep='int'           6.17(5.77+0.35)\n    4221.2: basic log -i --grep='int'           6.16(5.59+0.39)\n    4221.3: extended log -i --grep='int'        6.15(5.70+0.39)\n    4221.4: perl log -i --grep='int'            6.15(5.69+0.38)\n    4221.6: fixed log -i --grep='uncommon'      5.10(4.88+0.21)\n    4221.7: basic log -i --grep='uncommon'      5.04(4.76+0.25)\n    4221.8: extended log -i --grep='uncommon'   5.07(4.82+0.23)\n    4221.9: perl log -i --grep='uncommon'       5.03(4.78+0.22)\n    4221.11: fixed log -i --grep='æ'            5.93(5.65+0.25)\n    4221.12: basic log -i --grep='æ'            5.88(5.62+0.25)\n    4221.13: extended log -i --grep='æ'         6.02(5.69+0.29)\n    4221.14: perl log -i --grep='æ'             5.36(5.06+0.29)\n\nSee commit (\"perf: add a comparison test of grep regex engines\",\n2017-04-19) for details on the machine the above test run was executed\non.\n\nSigned-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n---\n t/perf/p4221-log-grep-engines-fixed.sh | 44 ++++++++++++++++++++++++++++++++++\n 1 file changed, 44 insertions(+)\n create mode 100755 t/perf/p4221-log-grep-engines-fixed.sh\n\ndiff --git a/t/perf/p4221-log-grep-engines-fixed.sh b/t/perf/p4221-log-grep-engines-fixed.sh\nnew file mode 100755\nindex 0000000000..060971265a\n--- /dev/null\n+++ b/t/perf/p4221-log-grep-engines-fixed.sh\n@@ -0,0 +1,44 @@\n+#!/bin/sh\n+\n+test_description=\"Comparison of git-log's --grep regex engines with -F\n+\n+Set GIT_PERF_4221_LOG_OPTS in the environment to pass options to\n+git-grep. Make sure to include a leading space,\n+e.g. GIT_PERF_4221_LOG_OPTS=' -i'. Some options to try:\n+\n+\t-i\n+\t--invert-grep\n+\t-i --invert-grep\n+\"\n+\n+. ./perf-lib.sh\n+\n+test_perf_large_repo\n+test_checkout_worktree\n+\n+for pattern in 'int' 'uncommon' 'æ'\n+do\n+\tfor engine in fixed basic extended perl\n+\tdo\n+\t\tif test $engine = \"perl\" && ! test_have_prereq PCRE\n+\t\tthen\n+\t\t\tprereq=\"PCRE\"\n+\t\telse\n+\t\t\tprereq=\"\"\n+\t\tfi\n+\t\ttest_perf $prereq \"$engine log$GIT_PERF_4221_LOG_OPTS --grep='$pattern'\" \"\n+\t\t\tgit -c grep.patternType=$engine log --pretty=format:%h$GIT_PERF_4221_LOG_OPTS --grep='$pattern' >'out.$engine' || :\n+\t\t\"\n+\tdone\n+\n+\ttest_expect_success \"assert that all engines found the same for$GIT_PERF_4221_LOG_OPTS '$pattern'\" '\n+\t\ttest_cmp out.fixed out.basic &&\n+\t\ttest_cmp out.fixed out.extended &&\n+\t\tif test_have_prereq PCRE\n+\t\tthen\n+\t\t\ttest_cmp out.fixed out.perl\n+\t\tfi\n+\t'\n+done\n+\n+test_done\n-- \n2.13.0.303.g4ebf302169\n\n"},{"id":"320751","messageId":"20170525194535.9324-25-avarab@gmail.com","threadId":"46045","inReplyTo":"20170525194535.9324-1-avarab@gmail.com","subject":"[PATCH v4 24/31] grep: change the internal PCRE macro names to be PCRE1","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2017-05-25T19:45:28Z","receivedAt":"2017-05-25T19:47:30Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"Change the internal USE_LIBPCRE define, & build options flag to use a\nnaming convention ending in PCRE1, without changing the long-standing\nUSE_LIBPCRE Makefile flag which enables this code.\n\nThis is for preparation for libpcre2 support where having things like\nUSE_LIBPCRE and USE_LIBPCRE2 in any more places than we absolutely\nneed to for backwards compatibility with old Makefile arguments would\nbe confusing.\n\nIn some ways it would be better to change everything that now uses\nUSE_LIBPCRE to use USE_LIBPCRE1, and to make specifying\nUSE_LIBPCRE (or --with-pcre) an error. This would impose a one-time\nburden on packagers of git to s/USE_LIBPCRE/USE_LIBPCRE1/ in their\nbuild scripts.\n\nHowever I'd like to leave the door open to making\nUSE_LIBPCRE=YesPlease eventually mean USE_LIBPCRE2=YesPlease,\ni.e. once PCRE v2 is ubiquitous enough that it makes sense to make it\nthe default.\n\nThis code and the USE_LIBPCRE Makefile argument was added in commit\n63e7e9d8b6 (\"git-grep: Learn PCRE\", 2011-05-09). At the time there was\nno indication that the PCRE project would release an entirely new &\nincompatible API around 3 years later.\n\nSigned-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n---\n Makefile      | 4 ++--\n grep.c        | 6 +++---\n grep.h        | 2 +-\n t/test-lib.sh | 2 +-\n 4 files changed, 7 insertions(+), 7 deletions(-)\n\ndiff --git a/Makefile b/Makefile\nindex d1587452f1..374fbc7e58 100644\n--- a/Makefile\n+++ b/Makefile\n@@ -1088,7 +1088,7 @@ ifdef NO_LIBGEN_H\n endif\n \n ifdef USE_LIBPCRE\n-\tBASIC_CFLAGS += -DUSE_LIBPCRE\n+\tBASIC_CFLAGS += -DUSE_LIBPCRE1\n \tifdef LIBPCREDIR\n \t\tBASIC_CFLAGS += -I$(LIBPCREDIR)/include\n \t\tEXTLIBS += -L$(LIBPCREDIR)/$(lib) $(CC_LD_DYNPATH)$(LIBPCREDIR)/$(lib)\n@@ -2240,7 +2240,7 @@ GIT-BUILD-OPTIONS: FORCE\n \t@echo TAR=\\''$(subst ','\\'',$(subst ','\\'',$(TAR)))'\\' >>$@+\n \t@echo NO_CURL=\\''$(subst ','\\'',$(subst ','\\'',$(NO_CURL)))'\\' >>$@+\n \t@echo NO_EXPAT=\\''$(subst ','\\'',$(subst ','\\'',$(NO_EXPAT)))'\\' >>$@+\n-\t@echo USE_LIBPCRE=\\''$(subst ','\\'',$(subst ','\\'',$(USE_LIBPCRE)))'\\' >>$@+\n+\t@echo USE_LIBPCRE1=\\''$(subst ','\\'',$(subst ','\\'',$(USE_LIBPCRE)))'\\' >>$@+\n \t@echo NO_PERL=\\''$(subst ','\\'',$(subst ','\\'',$(NO_PERL)))'\\' >>$@+\n \t@echo NO_PYTHON=\\''$(subst ','\\'',$(subst ','\\'',$(NO_PYTHON)))'\\' >>$@+\n \t@echo NO_UNIX_SOCKETS=\\''$(subst ','\\'',$(subst ','\\'',$(NO_UNIX_SOCKETS)))'\\' >>$@+\ndiff --git a/grep.c b/grep.c\nindex 18306bc605..7a3858a1c3 100644\n--- a/grep.c\n+++ b/grep.c\n@@ -333,7 +333,7 @@ static int has_null(const char *s, size_t len)\n \treturn 0;\n }\n \n-#ifdef USE_LIBPCRE\n+#ifdef USE_LIBPCRE1\n static void compile_pcre_regexp(struct grep_pat *p, const struct grep_opt *opt)\n {\n \tconst char *error;\n@@ -385,7 +385,7 @@ static void free_pcre_regexp(struct grep_pat *p)\n \tpcre_free(p->pcre_extra_info);\n \tpcre_free((void *)p->pcre_tables);\n }\n-#else /* !USE_LIBPCRE */\n+#else /* !USE_LIBPCRE1 */\n static void compile_pcre_regexp(struct grep_pat *p, const struct grep_opt *opt)\n {\n \tdie(\"cannot use Perl-compatible regexes when not compiled with USE_LIBPCRE\");\n@@ -400,7 +400,7 @@ static int pcrematch(struct grep_pat *p, const char *line, const char *eol,\n static void free_pcre_regexp(struct grep_pat *p)\n {\n }\n-#endif /* !USE_LIBPCRE */\n+#endif /* !USE_LIBPCRE1 */\n \n static int is_fixed(const char *s, size_t len)\n {\ndiff --git a/grep.h b/grep.h\nindex 267534ca24..073b0e4c92 100644\n--- a/grep.h\n+++ b/grep.h\n@@ -1,7 +1,7 @@\n #ifndef GREP_H\n #define GREP_H\n #include \"color.h\"\n-#ifdef USE_LIBPCRE\n+#ifdef USE_LIBPCRE1\n #include <pcre.h>\n #else\n typedef int pcre;\ndiff --git a/t/test-lib.sh b/t/test-lib.sh\nindex 04d857a42b..1d0f636cbd 100644\n--- a/t/test-lib.sh\n+++ b/t/test-lib.sh\n@@ -1014,7 +1014,7 @@ esac\n ( COLUMNS=1 && test $COLUMNS = 1 ) && test_set_prereq COLUMNS_CAN_BE_1\n test -z \"$NO_PERL\" && test_set_prereq PERL\n test -z \"$NO_PYTHON\" && test_set_prereq PYTHON\n-test -n \"$USE_LIBPCRE\" && test_set_prereq PCRE\n+test -n \"$USE_LIBPCRE1\" && test_set_prereq PCRE\n test -z \"$NO_GETTEXT\" && test_set_prereq GETTEXT\n \n # Can we rely on git's output in the C locale?\n-- \n2.13.0.303.g4ebf302169\n\n"},{"id":"320752","messageId":"20170525194535.9324-24-avarab@gmail.com","threadId":"46045","inReplyTo":"20170525194535.9324-1-avarab@gmail.com","subject":"[PATCH v4 23/31] grep: factor test for \\0 in grep patterns into a function","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2017-05-25T19:45:27Z","receivedAt":"2017-05-25T19:47:41Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"Factor the test for \\0 in grep patterns into a function. Since commit\n9eceddeec6 (\"Use kwset in grep\", 2011-08-21) any pattern containing a\n\\0 is considered fixed as regcomp() can't handle it.\n\nThis change makes later changes that make use of either has_null() or\nis_fixed() (but not both) smaller.\n\nWhile I'm at it make the comment conform to the style guide, i.e. add\nan opening \"/*\\n\".\n\nSigned-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n---\n grep.c | 22 +++++++++++++++-------\n 1 file changed, 15 insertions(+), 7 deletions(-)\n\ndiff --git a/grep.c b/grep.c\nindex bf6c2494fd..18306bc605 100644\n--- a/grep.c\n+++ b/grep.c\n@@ -321,6 +321,18 @@ static NORETURN void compile_regexp_failed(const struct grep_pat *p,\n \tdie(\"%s'%s': %s\", where, p->pattern, error);\n }\n \n+static int has_null(const char *s, size_t len)\n+{\n+\t/*\n+\t * regcomp cannot accept patterns with NULs so when using it\n+\t * we consider any pattern containing a NUL fixed.\n+\t */\n+\tif (memchr(s, 0, len))\n+\t\treturn 1;\n+\n+\treturn 0;\n+}\n+\n #ifdef USE_LIBPCRE\n static void compile_pcre_regexp(struct grep_pat *p, const struct grep_opt *opt)\n {\n@@ -394,12 +406,6 @@ static int is_fixed(const char *s, size_t len)\n {\n \tsize_t i;\n \n-\t/* regcomp cannot accept patterns with NULs so we\n-\t * consider any pattern containing a NUL fixed.\n-\t */\n-\tif (memchr(s, 0, len))\n-\t\treturn 1;\n-\n \tfor (i = 0; i < len; i++) {\n \t\tif (is_regex_special(s[i]))\n \t\t\treturn 0;\n@@ -451,7 +457,9 @@ static void compile_regexp(struct grep_pat *p, struct grep_opt *opt)\n \t * simple string match using kws.  p->fixed tells us if we\n \t * want to use kws.\n \t */\n-\tif (opt->fixed || is_fixed(p->pattern, p->patternlen))\n+\tif (opt->fixed ||\n+\t    has_null(p->pattern, p->patternlen) ||\n+\t    is_fixed(p->pattern, p->patternlen))\n \t\tp->fixed = !icase || ascii_only;\n \telse\n \t\tp->fixed = 0;\n-- \n2.13.0.303.g4ebf302169\n\n"},{"id":"320753","messageId":"20170525194535.9324-22-avarab@gmail.com","threadId":"46045","inReplyTo":"20170525194535.9324-1-avarab@gmail.com","subject":"[PATCH v4 21/31] grep: catch a missing enum in switch statement","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2017-05-25T19:45:25Z","receivedAt":"2017-05-25T19:47:43Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"Add a die(...) to a default case for the switch statement selecting\nbetween grep pattern types under --recurse-submodules.\n\nNormally this would be caught by -Wswitch, but the grep_pattern_type\ntype is converted to int by going through parse_options(). Changing\nthe argument type passed to compile_submodule_options() won't work,\nthe value will just get coerced. The -Wswitch-default warning will\nwarn about it, but that produces a lot of noise across the codebase,\nthis potential issue would be drowned in that noise.\n\nThus catching this at runtime is the least bad option. This won't ever\ntrigger in practice, but if a new pattern type were to be added this\ncatches an otherwise silent bug during development.\n\nSee commit 0281e487fd (\"grep: optionally recurse into submodules\",\n2016-12-16) for the initial addition of this code.\n\nSigned-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n---\n builtin/grep.c | 2 ++\n 1 file changed, 2 insertions(+)\n\ndiff --git a/builtin/grep.c b/builtin/grep.c\nindex 3ffb5b4e81..a191e2976b 100644\n--- a/builtin/grep.c\n+++ b/builtin/grep.c\n@@ -495,6 +495,8 @@ static void compile_submodule_options(const struct grep_opt *opt,\n \t\tbreak;\n \tcase GREP_PATTERN_TYPE_UNSPECIFIED:\n \t\tbreak;\n+\tdefault:\n+\t\tdie(\"BUG: Added a new grep pattern type without updating switch statement\");\n \t}\n \n \tfor (pattern = opt->pattern_list; pattern != NULL;\n-- \n2.13.0.303.g4ebf302169\n\n"},{"id":"320754","messageId":"20170525194535.9324-23-avarab@gmail.com","threadId":"46045","inReplyTo":"20170525194535.9324-1-avarab@gmail.com","subject":"[PATCH v4 22/31] grep: remove redundant regflags assignments","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2017-05-25T19:45:26Z","receivedAt":"2017-05-25T19:47:46Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"Remove redundant assignments to the \"regflags\" variable. This variable\nis only used set under GREP_PATTERN_TYPE_ERE, so there's no need to\nun-set it under GREP_PATTERN_TYPE_{FIXED,BRE,PCRE}.\n\nBack in 5010cb5fcc[1], we did do \"opt.regflags &= ~REG_EXTENDED\" upon\nseeing \"-G\" on the command line and flipped the bit on upon seeing\n\"-E\", but I think that was perfectly sensible and it would have been a\nbug if we didn't.  They were part of the command line parsing that\ncould have seen \"-E\" on the command line earlier.\n\nWhen cca2c172 (\"git-grep: do not die upon -F/-P when\ngrep.extendedRegexp is set.\", 2011-05-09) switched the command line\nparsing to \"read into a 'tentatively this is what we saw the last'\nvariable and then finally commit just once\", we didn't touch\nopt.regflags for PCRE and FIXED, but we still had to flip regflags\nbetween BRE and ERE, because parsing of grep.extendedregexp\nconfiguration variable directly touched opt.regflags back then, which\nwas done by b22520a3 (\"grep: allow -E and -n to be turned on by\ndefault via configuration\", 2011-03-30).\n\nWhen 84befcd0 (\"grep: add a grep.patternType configuration setting\",\n2012-08-03) introduced extended_regexp_option field, we stopped\nflipping regflags while reading the configuration, and that was when\nwe should have noticed and stopped dropping REG_EXTENDED bit in the\n\"now we can commit what type to use\" helper function.\n\nThere is no reason to do this anymore, so stop doing it, more to\nreduce \"wait this is used under fixed/BRE/PCRE how?\" confusion when\nreading the code, than to to save ourselves trivial CPU cycles by\nremoving one assignment.\n\n1. \"built-in \"git grep\"\", 2006-04-30.\n\nSigned-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n---\n grep.c | 6 +-----\n 1 file changed, 1 insertion(+), 5 deletions(-)\n\ndiff --git a/grep.c b/grep.c\nindex 47cee45067..bf6c2494fd 100644\n--- a/grep.c\n+++ b/grep.c\n@@ -179,7 +179,6 @@ static void grep_set_pattern_type_option(enum grep_pattern_type pattern_type, st\n \tcase GREP_PATTERN_TYPE_BRE:\n \t\topt->fixed = 0;\n \t\topt->pcre = 0;\n-\t\topt->regflags &= ~REG_EXTENDED;\n \t\tbreak;\n \n \tcase GREP_PATTERN_TYPE_ERE:\n@@ -191,13 +190,11 @@ static void grep_set_pattern_type_option(enum grep_pattern_type pattern_type, st\n \tcase GREP_PATTERN_TYPE_FIXED:\n \t\topt->fixed = 1;\n \t\topt->pcre = 0;\n-\t\topt->regflags &= ~REG_EXTENDED;\n \t\tbreak;\n \n \tcase GREP_PATTERN_TYPE_PCRE:\n \t\topt->fixed = 0;\n \t\topt->pcre = 1;\n-\t\topt->regflags &= ~REG_EXTENDED;\n \t\tbreak;\n \t}\n }\n@@ -415,10 +412,9 @@ static void compile_fixed_regexp(struct grep_pat *p, struct grep_opt *opt)\n {\n \tstruct strbuf sb = STRBUF_INIT;\n \tint err;\n-\tint regflags;\n+\tint regflags = opt->regflags;\n \n \tbasic_regex_quote_buf(&sb, p->pattern);\n-\tregflags = opt->regflags & ~REG_EXTENDED;\n \tif (opt->ignore_case)\n \t\tregflags |= REG_ICASE;\n \terr = regcomp(&p->regexp, sb.buf, regflags);\n-- \n2.13.0.303.g4ebf302169\n\n"},{"id":"320755","messageId":"20170525194535.9324-29-avarab@gmail.com","threadId":"46045","inReplyTo":"20170525194535.9324-1-avarab@gmail.com","subject":"[PATCH v4 28/31] pack-objects & index-pack: add test for --threads warning","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2017-05-25T19:45:32Z","receivedAt":"2017-05-25T19:47:48Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"Add a test for the warning that's emitted when --threads or\npack.threads is provided under NO_PTHREADS=YesPlease. This uses the\nnew PTHREADS prerequisite.\n\nThe assertion for C_LOCALE_OUTPUT in the latter test is currently\nredundant, since unlike index-pack the pack-objects warnings aren't\ni18n'd. However they might be changed to be i18n'd in the future, and\nthere's no harm in future-proofing the test.\n\nThere's an existing bug in the implementation of pack-objects which\nthis test currently tests for as-is. Details about the bug & the fix\nare included in a follow-up change.\n\nSigned-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n---\n t/t5300-pack-object.sh | 36 ++++++++++++++++++++++++++++++++++++\n 1 file changed, 36 insertions(+)\n\ndiff --git a/t/t5300-pack-object.sh b/t/t5300-pack-object.sh\nindex 43a672c345..6ed23ee1d2 100755\n--- a/t/t5300-pack-object.sh\n+++ b/t/t5300-pack-object.sh\n@@ -421,6 +421,42 @@ test_expect_success 'index-pack <pack> works in non-repo' '\n \ttest_path_is_file foo.idx\n '\n \n+test_expect_success !PTHREADS,C_LOCALE_OUTPUT 'index-pack --threads=N or pack.threads=N warns when no pthreads' '\n+\ttest_must_fail git index-pack --threads=2 2>err &&\n+\tgrep ^warning: err >warnings &&\n+\ttest_line_count = 1 warnings &&\n+\tgrep -F \"no threads support, ignoring --threads=2\" err &&\n+\n+\ttest_must_fail git -c pack.threads=2 index-pack 2>err &&\n+\tgrep ^warning: err >warnings &&\n+\ttest_line_count = 1 warnings &&\n+\tgrep -F \"no threads support, ignoring pack.threads\" err &&\n+\n+\ttest_must_fail git -c pack.threads=2 index-pack --threads=4 2>err &&\n+\tgrep ^warning: err >warnings &&\n+\ttest_line_count = 2 warnings &&\n+\tgrep -F \"no threads support, ignoring --threads=4\" err &&\n+\tgrep -F \"no threads support, ignoring pack.threads\" err\n+'\n+\n+test_expect_success !PTHREADS,C_LOCALE_OUTPUT 'pack-objects --threads=N or pack.threads=N warns when no pthreads' '\n+\tgit pack-objects --threads=2 --stdout --all </dev/null >/dev/null 2>err &&\n+\tgrep ^warning: err >warnings &&\n+\ttest_line_count = 1 warnings &&\n+\tgrep -F \"no threads support, ignoring --threads\" err &&\n+\n+\tgit -c pack.threads=2 pack-objects --stdout --all </dev/null >/dev/null 2>err &&\n+\tgrep ^warning: err >warnings &&\n+\ttest_must_fail test_line_count = 1 warnings &&\n+\tgrep -F \"no threads support, ignoring pack.threads\" err &&\n+\n+\tgit -c pack.threads=2 pack-objects --threads=4 --stdout --all </dev/null >/dev/null 2>err &&\n+\tgrep ^warning: err >warnings &&\n+\ttest_line_count = 2 warnings &&\n+\tgrep -F \"no threads support, ignoring --threads\" err &&\n+\tgrep -F \"no threads support, ignoring pack.threads\" err\n+'\n+\n #\n # WARNING!\n #\n-- \n2.13.0.303.g4ebf302169\n\n"},{"id":"320756","messageId":"20170525194535.9324-31-avarab@gmail.com","threadId":"46045","inReplyTo":"20170525194535.9324-1-avarab@gmail.com","subject":"[PATCH v4 30/31] grep: given --threads with NO_PTHREADS=YesPlease, warn","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2017-05-25T19:45:34Z","receivedAt":"2017-05-25T19:47:50Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"Add a warning about missing thread support when grep.threads or\n--threads is set to a non 0 (default) or 1 (no parallelism) value\nunder NO_PTHREADS=YesPlease.\n\nThis is for consistency with the index-pack & pack-objects commands,\nwhich also take a --threads option & are configurable via\npack.threads, and have long warned about the same under\nNO_PTHREADS=YesPlease.\n\nSigned-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n---\n builtin/grep.c  | 13 +++++++++++++\n t/t7810-grep.sh | 18 ++++++++++++++++++\n 2 files changed, 31 insertions(+)\n\ndiff --git a/builtin/grep.c b/builtin/grep.c\nindex a191e2976b..3c721b75a5 100644\n--- a/builtin/grep.c\n+++ b/builtin/grep.c\n@@ -289,6 +289,17 @@ static int grep_cmd_config(const char *var, const char *value, void *cb)\n \t\tif (num_threads < 0)\n \t\t\tdie(_(\"invalid number of threads specified (%d) for %s\"),\n \t\t\t    num_threads, var);\n+#ifdef NO_PTHREADS\n+\t\telse if (num_threads && num_threads != 1) {\n+\t\t\t/*\n+\t\t\t * TRANSLATORS: %s is the configuration\n+\t\t\t * variable for tweaking threads, currently\n+\t\t\t * grep.threads\n+\t\t\t */\n+\t\t\twarning(_(\"no threads support, ignoring %s\"), var);\n+\t\t\tnum_threads = 0;\n+\t\t}\n+#endif\n \t}\n \n \treturn st;\n@@ -1229,6 +1240,8 @@ int cmd_grep(int argc, const char **argv, const char *prefix)\n \telse if (num_threads < 0)\n \t\tdie(_(\"invalid number of threads specified (%d)\"), num_threads);\n #else\n+\tif (num_threads)\n+\t\twarning(_(\"no threads support, ignoring --threads\"));\n \tnum_threads = 0;\n #endif\n \ndiff --git a/t/t7810-grep.sh b/t/t7810-grep.sh\nindex 561709ef6a..f106387820 100755\n--- a/t/t7810-grep.sh\n+++ b/t/t7810-grep.sh\n@@ -791,6 +791,24 @@ do\n \t\"\n done\n \n+test_expect_success !PTHREADS,C_LOCALE_OUTPUT 'grep --threads=N or pack.threads=N warns when no pthreads' '\n+\tgit grep --threads=2 Hello hello_world 2>err &&\n+\tgrep ^warning: err >warnings &&\n+\ttest_line_count = 1 warnings &&\n+\tgrep -F \"no threads support, ignoring --threads\" err &&\n+\tgit -c grep.threads=2 grep Hello hello_world 2>err &&\n+\tgrep ^warning: err >warnings &&\n+\ttest_line_count = 1 warnings &&\n+\tgrep -F \"no threads support, ignoring grep.threads\" err &&\n+\tgit -c grep.threads=2 grep --threads=4 Hello hello_world 2>err &&\n+\tgrep ^warning: err >warnings &&\n+\ttest_line_count = 2 warnings &&\n+\tgrep -F \"no threads support, ignoring --threads\" err &&\n+\tgrep -F \"no threads support, ignoring grep.threads\" err &&\n+\tgit -c grep.threads=0 grep --threads=0 Hello hello_world 2>err &&\n+\ttest_line_count = 0 err\n+'\n+\n test_expect_success 'grep from a subdirectory to search wider area (1)' '\n \tmkdir -p s &&\n \t(\n-- \n2.13.0.303.g4ebf302169\n\n"},{"id":"320757","messageId":"20170525194535.9324-26-avarab@gmail.com","threadId":"46045","inReplyTo":"20170525194535.9324-1-avarab@gmail.com","subject":"[PATCH v4 25/31] grep: change internal *pcre* variable & function names to be *pcre1*","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2017-05-25T19:45:29Z","receivedAt":"2017-05-25T19:47:54Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"Change the internal PCRE variable & function names to have a \"1\"\nsuffix. This is for preparation for libpcre2 support, where having\nnon-versioned names would be confusing.\n\nAn earlier change in this series (\"grep: change the internal PCRE\nmacro names to be PCRE1\", 2017-04-07) elaborates on the motivations\nbehind this change.\n\nSigned-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n---\n grep.c | 52 ++++++++++++++++++++++++++--------------------------\n grep.h |  8 ++++----\n 2 files changed, 30 insertions(+), 30 deletions(-)\n\ndiff --git a/grep.c b/grep.c\nindex 7a3858a1c3..2d54baeaa3 100644\n--- a/grep.c\n+++ b/grep.c\n@@ -178,23 +178,23 @@ static void grep_set_pattern_type_option(enum grep_pattern_type pattern_type, st\n \n \tcase GREP_PATTERN_TYPE_BRE:\n \t\topt->fixed = 0;\n-\t\topt->pcre = 0;\n+\t\topt->pcre1 = 0;\n \t\tbreak;\n \n \tcase GREP_PATTERN_TYPE_ERE:\n \t\topt->fixed = 0;\n-\t\topt->pcre = 0;\n+\t\topt->pcre1 = 0;\n \t\topt->regflags |= REG_EXTENDED;\n \t\tbreak;\n \n \tcase GREP_PATTERN_TYPE_FIXED:\n \t\topt->fixed = 1;\n-\t\topt->pcre = 0;\n+\t\topt->pcre1 = 0;\n \t\tbreak;\n \n \tcase GREP_PATTERN_TYPE_PCRE:\n \t\topt->fixed = 0;\n-\t\topt->pcre = 1;\n+\t\topt->pcre1 = 1;\n \t\tbreak;\n \t}\n }\n@@ -334,7 +334,7 @@ static int has_null(const char *s, size_t len)\n }\n \n #ifdef USE_LIBPCRE1\n-static void compile_pcre_regexp(struct grep_pat *p, const struct grep_opt *opt)\n+static void compile_pcre1_regexp(struct grep_pat *p, const struct grep_opt *opt)\n {\n \tconst char *error;\n \tint erroffset;\n@@ -342,23 +342,23 @@ static void compile_pcre_regexp(struct grep_pat *p, const struct grep_opt *opt)\n \n \tif (opt->ignore_case) {\n \t\tif (has_non_ascii(p->pattern))\n-\t\t\tp->pcre_tables = pcre_maketables();\n+\t\t\tp->pcre1_tables = pcre_maketables();\n \t\toptions |= PCRE_CASELESS;\n \t}\n \tif (is_utf8_locale() && has_non_ascii(p->pattern))\n \t\toptions |= PCRE_UTF8;\n \n-\tp->pcre_regexp = pcre_compile(p->pattern, options, &error, &erroffset,\n-\t\t\t\t      p->pcre_tables);\n-\tif (!p->pcre_regexp)\n+\tp->pcre1_regexp = pcre_compile(p->pattern, options, &error, &erroffset,\n+\t\t\t\t      p->pcre1_tables);\n+\tif (!p->pcre1_regexp)\n \t\tcompile_regexp_failed(p, error);\n \n-\tp->pcre_extra_info = pcre_study(p->pcre_regexp, 0, &error);\n-\tif (!p->pcre_extra_info && error)\n+\tp->pcre1_extra_info = pcre_study(p->pcre1_regexp, 0, &error);\n+\tif (!p->pcre1_extra_info && error)\n \t\tdie(\"%s\", error);\n }\n \n-static int pcrematch(struct grep_pat *p, const char *line, const char *eol,\n+static int pcre1match(struct grep_pat *p, const char *line, const char *eol,\n \t\tregmatch_t *match, int eflags)\n {\n \tint ovector[30], ret, flags = 0;\n@@ -366,7 +366,7 @@ static int pcrematch(struct grep_pat *p, const char *line, const char *eol,\n \tif (eflags & REG_NOTBOL)\n \t\tflags |= PCRE_NOTBOL;\n \n-\tret = pcre_exec(p->pcre_regexp, p->pcre_extra_info, line, eol - line,\n+\tret = pcre_exec(p->pcre1_regexp, p->pcre1_extra_info, line, eol - line,\n \t\t\t0, flags, ovector, ARRAY_SIZE(ovector));\n \tif (ret < 0 && ret != PCRE_ERROR_NOMATCH)\n \t\tdie(\"pcre_exec failed with error code %d\", ret);\n@@ -379,25 +379,25 @@ static int pcrematch(struct grep_pat *p, const char *line, const char *eol,\n \treturn ret;\n }\n \n-static void free_pcre_regexp(struct grep_pat *p)\n+static void free_pcre1_regexp(struct grep_pat *p)\n {\n-\tpcre_free(p->pcre_regexp);\n-\tpcre_free(p->pcre_extra_info);\n-\tpcre_free((void *)p->pcre_tables);\n+\tpcre_free(p->pcre1_regexp);\n+\tpcre_free(p->pcre1_extra_info);\n+\tpcre_free((void *)p->pcre1_tables);\n }\n #else /* !USE_LIBPCRE1 */\n-static void compile_pcre_regexp(struct grep_pat *p, const struct grep_opt *opt)\n+static void compile_pcre1_regexp(struct grep_pat *p, const struct grep_opt *opt)\n {\n \tdie(\"cannot use Perl-compatible regexes when not compiled with USE_LIBPCRE\");\n }\n \n-static int pcrematch(struct grep_pat *p, const char *line, const char *eol,\n+static int pcre1match(struct grep_pat *p, const char *line, const char *eol,\n \t\tregmatch_t *match, int eflags)\n {\n \treturn 1;\n }\n \n-static void free_pcre_regexp(struct grep_pat *p)\n+static void free_pcre1_regexp(struct grep_pat *p)\n {\n }\n #endif /* !USE_LIBPCRE1 */\n@@ -479,8 +479,8 @@ static void compile_regexp(struct grep_pat *p, struct grep_opt *opt)\n \t\treturn;\n \t}\n \n-\tif (opt->pcre) {\n-\t\tcompile_pcre_regexp(p, opt);\n+\tif (opt->pcre1) {\n+\t\tcompile_pcre1_regexp(p, opt);\n \t\treturn;\n \t}\n \n@@ -836,8 +836,8 @@ void free_grep_patterns(struct grep_opt *opt)\n \t\tcase GREP_PATTERN_BODY:\n \t\t\tif (p->kws)\n \t\t\t\tkwsfree(p->kws);\n-\t\t\telse if (p->pcre_regexp)\n-\t\t\t\tfree_pcre_regexp(p);\n+\t\t\telse if (p->pcre1_regexp)\n+\t\t\t\tfree_pcre1_regexp(p);\n \t\t\telse\n \t\t\t\tregfree(&p->regexp);\n \t\t\tfree(p->pattern);\n@@ -916,8 +916,8 @@ static int patmatch(struct grep_pat *p, char *line, char *eol,\n \n \tif (p->fixed)\n \t\thit = !fixmatch(p, line, eol, match);\n-\telse if (p->pcre_regexp)\n-\t\thit = !pcrematch(p, line, eol, match, eflags);\n+\telse if (p->pcre1_regexp)\n+\t\thit = !pcre1match(p, line, eol, match, eflags);\n \telse\n \t\thit = !regexec_buf(&p->regexp, line, eol - line, 1, match,\n \t\t\t\t   eflags);\ndiff --git a/grep.h b/grep.h\nindex 073b0e4c92..38ac82b638 100644\n--- a/grep.h\n+++ b/grep.h\n@@ -46,9 +46,9 @@ struct grep_pat {\n \tsize_t patternlen;\n \tenum grep_header_field field;\n \tregex_t regexp;\n-\tpcre *pcre_regexp;\n-\tpcre_extra *pcre_extra_info;\n-\tconst unsigned char *pcre_tables;\n+\tpcre *pcre1_regexp;\n+\tpcre_extra *pcre1_extra_info;\n+\tconst unsigned char *pcre1_tables;\n \tkwset_t kws;\n \tunsigned fixed:1;\n \tunsigned ignore_case:1;\n@@ -111,7 +111,7 @@ struct grep_opt {\n \tint allow_textconv;\n \tint extended;\n \tint use_reflog_filter;\n-\tint pcre;\n+\tint pcre1;\n \tint relative;\n \tint pathname;\n \tint null_following_name;\n-- \n2.13.0.303.g4ebf302169\n\n"},{"id":"320758","messageId":"20170525194535.9324-32-avarab@gmail.com","threadId":"46045","inReplyTo":"20170525194535.9324-1-avarab@gmail.com","subject":"[PATCH v4 31/31] grep: assert that threading is enabled when calling grep_{lock,unlock}","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2017-05-25T19:45:35Z","receivedAt":"2017-05-25T19:47:58Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"Change the grep_{lock,unlock} functions to assert that num_threads is\ntrue, instead of only locking & unlocking the pthread mutex lock when\nit is.\n\nThese functions are never called when num_threads isn't true, this\nlogic has gone through multiple iterations since the initial\nintroduction of grep threading in commit 5b594f457a (\"Threaded grep\",\n2010-01-25), but ever since then they'd only be called if num_threads\nwas true, so this check made the code confusing to read.\n\nReplace the check with an assertion, so that it's clear to the reader\nthat this code path is never taken unless we're spawning threads.\n\nSigned-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n---\n builtin/grep.c | 8 ++++----\n 1 file changed, 4 insertions(+), 4 deletions(-)\n\ndiff --git a/builtin/grep.c b/builtin/grep.c\nindex 3c721b75a5..b1095362fb 100644\n--- a/builtin/grep.c\n+++ b/builtin/grep.c\n@@ -73,14 +73,14 @@ static pthread_mutex_t grep_mutex;\n \n static inline void grep_lock(void)\n {\n-\tif (num_threads)\n-\t\tpthread_mutex_lock(&grep_mutex);\n+\tassert(num_threads);\n+\tpthread_mutex_lock(&grep_mutex);\n }\n \n static inline void grep_unlock(void)\n {\n-\tif (num_threads)\n-\t\tpthread_mutex_unlock(&grep_mutex);\n+\tassert(num_threads);\n+\tpthread_mutex_unlock(&grep_mutex);\n }\n \n /* Signalled when a new work_item is added to todo. */\n-- \n2.13.0.303.g4ebf302169\n\n"},{"id":"320759","messageId":"20170525194535.9324-30-avarab@gmail.com","threadId":"46045","inReplyTo":"20170525194535.9324-1-avarab@gmail.com","subject":"[PATCH v4 29/31] pack-objects: fix buggy warning about threads","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2017-05-25T19:45:33Z","receivedAt":"2017-05-25T19:48:01Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"Fix a buggy warning about threads under NO_PTHREADS=YesPlease. Due to\nre-using the delta_search_threads variable for both the state of the\n\"pack.threads\" config & the --threads option, setting \"pack.threads\"\nbut not supplying --threads would trigger the warning for both\n\"pack.threads\" & --threads.\n\nSolve this bug by resetting the delta_search_threads variable in\ngit_pack_config(), it might then be set by --threads again and be\nsubsequently warned about, as the test I'm changing here asserts.\n\nSigned-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n---\n builtin/pack-objects.c | 4 +++-\n t/t5300-pack-object.sh | 2 +-\n 2 files changed, 4 insertions(+), 2 deletions(-)\n\ndiff --git a/builtin/pack-objects.c b/builtin/pack-objects.c\nindex 9b4ba8a80d..efa21a15dd 100644\n--- a/builtin/pack-objects.c\n+++ b/builtin/pack-objects.c\n@@ -2472,8 +2472,10 @@ static int git_pack_config(const char *k, const char *v, void *cb)\n \t\t\tdie(\"invalid number of threads specified (%d)\",\n \t\t\t    delta_search_threads);\n #ifdef NO_PTHREADS\n-\t\tif (delta_search_threads != 1)\n+\t\tif (delta_search_threads != 1) {\n \t\t\twarning(\"no threads support, ignoring %s\", k);\n+\t\t\tdelta_search_threads = 0;\n+\t\t}\n #endif\n \t\treturn 0;\n \t}\ndiff --git a/t/t5300-pack-object.sh b/t/t5300-pack-object.sh\nindex 6ed23ee1d2..9c68b99251 100755\n--- a/t/t5300-pack-object.sh\n+++ b/t/t5300-pack-object.sh\n@@ -447,7 +447,7 @@ test_expect_success !PTHREADS,C_LOCALE_OUTPUT 'pack-objects --threads=N or pack.\n \n \tgit -c pack.threads=2 pack-objects --stdout --all </dev/null >/dev/null 2>err &&\n \tgrep ^warning: err >warnings &&\n-\ttest_must_fail test_line_count = 1 warnings &&\n+\ttest_line_count = 1 warnings &&\n \tgrep -F \"no threads support, ignoring pack.threads\" err &&\n \n \tgit -c pack.threads=2 pack-objects --threads=4 --stdout --all </dev/null >/dev/null 2>err &&\n-- \n2.13.0.303.g4ebf302169\n\n"},{"id":"320760","messageId":"20170525194535.9324-28-avarab@gmail.com","threadId":"46045","inReplyTo":"20170525194535.9324-1-avarab@gmail.com","subject":"[PATCH v4 27/31] test-lib: add a PTHREADS prerequisite","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2017-05-25T19:45:31Z","receivedAt":"2017-05-25T19:48:04Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"Add a PTHREADS prerequisite which is false when git is compiled with\nNO_PTHREADS=YesPlease.\n\nThere's lots of custom code that runs when threading isn't available,\nbut before this prerequisite there was no way to test it.\n\nSigned-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n---\n Makefile      | 1 +\n t/README      | 4 ++++\n t/test-lib.sh | 1 +\n 3 files changed, 6 insertions(+)\n\ndiff --git a/Makefile b/Makefile\nindex 374fbc7e58..a79274e5e6 100644\n--- a/Makefile\n+++ b/Makefile\n@@ -2242,6 +2242,7 @@ GIT-BUILD-OPTIONS: FORCE\n \t@echo NO_EXPAT=\\''$(subst ','\\'',$(subst ','\\'',$(NO_EXPAT)))'\\' >>$@+\n \t@echo USE_LIBPCRE1=\\''$(subst ','\\'',$(subst ','\\'',$(USE_LIBPCRE)))'\\' >>$@+\n \t@echo NO_PERL=\\''$(subst ','\\'',$(subst ','\\'',$(NO_PERL)))'\\' >>$@+\n+\t@echo NO_PTHREADS=\\''$(subst ','\\'',$(subst ','\\'',$(NO_PTHREADS)))'\\' >>$@+\n \t@echo NO_PYTHON=\\''$(subst ','\\'',$(subst ','\\'',$(NO_PYTHON)))'\\' >>$@+\n \t@echo NO_UNIX_SOCKETS=\\''$(subst ','\\'',$(subst ','\\'',$(NO_UNIX_SOCKETS)))'\\' >>$@+\n \t@echo PAGER_ENV=\\''$(subst ','\\'',$(subst ','\\'',$(PAGER_ENV)))'\\' >>$@+\ndiff --git a/t/README b/t/README\nindex a90cb62583..2f95860369 100644\n--- a/t/README\n+++ b/t/README\n@@ -817,6 +817,10 @@ use these, and \"test_set_prereq\" for how to define your own.\n    Test is run on a filesystem which converts decomposed utf-8 (nfd)\n    to precomposed utf-8 (nfc).\n \n+ - PTHREADS\n+\n+   Git wasn't compiled with NO_PTHREADS=YesPlease.\n+\n Tips for Writing Tests\n ----------------------\n \ndiff --git a/t/test-lib.sh b/t/test-lib.sh\nindex 1d0f636cbd..43529451f9 100644\n--- a/t/test-lib.sh\n+++ b/t/test-lib.sh\n@@ -1013,6 +1013,7 @@ esac\n \n ( COLUMNS=1 && test $COLUMNS = 1 ) && test_set_prereq COLUMNS_CAN_BE_1\n test -z \"$NO_PERL\" && test_set_prereq PERL\n+test -z \"$NO_PTHREADS\" && test_set_prereq PTHREADS\n test -z \"$NO_PYTHON\" && test_set_prereq PYTHON\n test -n \"$USE_LIBPCRE1\" && test_set_prereq PCRE\n test -z \"$NO_GETTEXT\" && test_set_prereq GETTEXT\n-- \n2.13.0.303.g4ebf302169\n\n"},{"id":"320761","messageId":"20170525194535.9324-27-avarab@gmail.com","threadId":"46045","inReplyTo":"20170525194535.9324-1-avarab@gmail.com","subject":"[PATCH v4 26/31] grep: move is_fixed() earlier to avoid forward declaration","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2017-05-25T19:45:30Z","receivedAt":"2017-05-25T19:48:06Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"Move the is_fixed() function which are currently only used in\ncompile_regexp() earlier so it can be used in the PCRE family of\nfunctions in a later change.\n\nSigned-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n---\n grep.c | 24 ++++++++++++------------\n 1 file changed, 12 insertions(+), 12 deletions(-)\n\ndiff --git a/grep.c b/grep.c\nindex 2d54baeaa3..d03d424e5c 100644\n--- a/grep.c\n+++ b/grep.c\n@@ -321,6 +321,18 @@ static NORETURN void compile_regexp_failed(const struct grep_pat *p,\n \tdie(\"%s'%s': %s\", where, p->pattern, error);\n }\n \n+static int is_fixed(const char *s, size_t len)\n+{\n+\tsize_t i;\n+\n+\tfor (i = 0; i < len; i++) {\n+\t\tif (is_regex_special(s[i]))\n+\t\t\treturn 0;\n+\t}\n+\n+\treturn 1;\n+}\n+\n static int has_null(const char *s, size_t len)\n {\n \t/*\n@@ -402,18 +414,6 @@ static void free_pcre1_regexp(struct grep_pat *p)\n }\n #endif /* !USE_LIBPCRE1 */\n \n-static int is_fixed(const char *s, size_t len)\n-{\n-\tsize_t i;\n-\n-\tfor (i = 0; i < len; i++) {\n-\t\tif (is_regex_special(s[i]))\n-\t\t\treturn 0;\n-\t}\n-\n-\treturn 1;\n-}\n-\n static void compile_fixed_regexp(struct grep_pat *p, struct grep_opt *opt)\n {\n \tstruct strbuf sb = STRBUF_INIT;\n-- \n2.13.0.303.g4ebf302169\n\n"}]}