{"thread":{"id":"45930","subject":"[PATCH 00/29] Easy to review grep & pre-PCRE changes","startedAt":"2017-05-11T09:18:55Z","lastAt":"2017-05-30T23:03:28Z","messageCount":61,"participants":["Ævar Arnfjörð Bjarmason","Brandon Williams","Stefan Beller","Jonathan Nieder","Johannes Sixt","Junio C Hamano","Jiang Xin"],"isPatch":true,"patchVersion":1,"patchTotal":29},"messages":[{"id":"319344","messageId":"20170511091829.5634-1-avarab@gmail.com","threadId":"45930","inReplyTo":null,"subject":"[PATCH 00/29] Easy to review grep & pre-PCRE changes","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2017-05-11T09:18:00Z","receivedAt":"2017-05-11T09:18:55Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"Easy to review? 29 patches? Are you kidding me?!\n\nI thought about how to split up my sprawling PCRE v2 series which\ncan't easily be broken up because a lot of it is trivial setup code\nneeded for later patches, or things that would result in lots of merge\nconflicts.\n\nThis is an attempt to make that as easy as possible for reviewers\nthese are only things that should be obviously correct, i.e.:\n\n * Comments\n * Trivial documentation changes\n * Tests for existing behavior\n * New perf tests used for later patch submissions\n * Moving code around or renaming variables which introduces no\n   functional changes, makes later patches smaller.\n * Adding an assert() to existing code to self-document something\n   that's true 100% of the time now.\n\nThe only exception to that is 27 and 28 which are trivial bugfixes /\nconsistency fixes to pack-objects & grep in how they warn about\ninvalid thread configuration under NO_PTHREADS=Y.\n\nÆvar Arnfjörð Bjarmason (29):\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  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  perf: add a GIT_PERF_MAKE_COMMAND for when *_MAKE_OPTS won't do\n  perf: emit progress output when unpacking & building\n  perf: add a performance comparison test of grep -G, -E and -P\n  perf: add a performance comparison of fixed-string grep\n  grep: catch a missing enum in switch statement\n  grep: remove redundant regflags assignment under PCRE\n  grep: remove redundant `regflags &= ~REG_EXTENDED` assignments\n  grep: factor test for \\0 in grep patterns into a function\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 two functions 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\n Documentation/git-grep.txt         |   7 +-\n Documentation/rev-list-options.txt |   8 +-\n Makefile                           |  14 ++-\n builtin/grep.c                     |  25 ++++-\n builtin/pack-objects.c             |   4 +-\n configure.ac                       |  12 ++-\n grep.c                             | 107 +++++++++---------\n grep.h                             |  10 +-\n t/README                           |   8 +-\n t/perf/README                      |  19 +++-\n t/perf/p7820-grep-engines.sh       |  35 ++++++\n t/perf/p7821-grep-engines-fixed.sh |  27 +++++\n t/perf/run                         |  13 ++-\n t/t4202-log.sh                     |  80 +++++++++++++-\n t/t5300-pack-object.sh             |  33 ++++++\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 21 files changed, 632 insertions(+), 235 deletions(-)\n create mode 100755 t/perf/p7820-grep-engines.sh\n create mode 100755 t/perf/p7821-grep-engines-fixed.sh\n\n-- \n2.11.0\n\n"},{"id":"319345","messageId":"20170511091829.5634-3-avarab@gmail.com","threadId":"45930","inReplyTo":"20170511091829.5634-1-avarab@gmail.com","subject":"[PATCH 02/29] grep & rev-list doc: stop promising libpcre for --perl-regexp","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2017-05-11T09:18:02Z","receivedAt":"2017-05-11T09:19:00Z","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.11.0\n\n"},{"id":"319346","messageId":"20170511091829.5634-4-avarab@gmail.com","threadId":"45930","inReplyTo":"20170511091829.5634-1-avarab@gmail.com","subject":"[PATCH 03/29] test-lib: rename the LIBPCRE prerequisite to PCRE","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2017-05-11T09:18:03Z","receivedAt":"2017-05-11T09:19:03Z","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 13b5696822..6abf1d1918 100644\n--- a/t/test-lib.sh\n+++ b/t/test-lib.sh\n@@ -1010,7 +1010,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.11.0\n\n"},{"id":"319347","messageId":"20170511091829.5634-2-avarab@gmail.com","threadId":"45930","inReplyTo":"20170511091829.5634-1-avarab@gmail.com","subject":"[PATCH 01/29] Makefile & configure: reword inaccurate comment about PCRE","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2017-05-11T09:18:01Z","receivedAt":"2017-05-11T09:19:05Z","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.11.0\n\n"},{"id":"319348","messageId":"20170511091829.5634-5-avarab@gmail.com","threadId":"45930","inReplyTo":"20170511091829.5634-1-avarab@gmail.com","subject":"[PATCH 04/29] log: add exhaustive tests for pattern style options & config","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2017-05-11T09:18:04Z","receivedAt":"2017-05-11T09:19:08Z","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 | 77 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++-\n 1 file changed, 76 insertions(+), 1 deletion(-)\n\ndiff --git a/t/t4202-log.sh b/t/t4202-log.sh\nindex f577990716..6d1411abea 100755\n--- a/t/t4202-log.sh\n+++ b/t/t4202-log.sh\n@@ -262,7 +262,23 @@ 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+\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+\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+\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 +296,65 @@ 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+\t\ttest_commit \"(1|2)\" file B &&\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\tgit -c grep.patternType=fixed log --pretty=tformat:%s \\\n+\t\t\t--grep=\"(1|2)\" >actual.fixed &&\n+\t\tgit -c grep.patternType=basic log --pretty=tformat:%s \\\n+\t\t\t--grep=\"(.|.)\" >actual.basic &&\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\tgit -c grep.patternType=perl log --pretty=tformat:%s \\\n+\t\t\t\t--grep=\"[\\d]\\|\" >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+\t\tif test_have_prereq PCRE\n+\t\tthen\n+\t\t\ttest_cmp expect.perl actual.perl\n+\t\tfi &&\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\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\tif test_have_prereq PCRE\n+\t\tthen\n+\t\t\ttest_cmp expect.perl actual.perl.long-arg\n+\t\tfi\n+\t)\n+'\n+\n cat > expect <<EOF\n * Second\n * sixth\n-- \n2.11.0\n\n"},{"id":"319349","messageId":"20170511091829.5634-7-avarab@gmail.com","threadId":"45930","inReplyTo":"20170511091829.5634-1-avarab@gmail.com","subject":"[PATCH 06/29] grep: add a test for backreferences in PCRE patterns","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2017-05-11T09:18:06Z","receivedAt":"2017-05-11T09:19:13Z","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.11.0\n\n"},{"id":"319350","messageId":"20170511091829.5634-6-avarab@gmail.com","threadId":"45930","inReplyTo":"20170511091829.5634-1-avarab@gmail.com","subject":"[PATCH 05/29] grep: add a test asserting that --perl-regexp dies when !PCRE","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2017-05-11T09:18:05Z","receivedAt":"2017-05-11T09:19:16Z","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  |  3 +++\n t/t7810-grep.sh | 12 ++++++++++++\n 2 files changed, 15 insertions(+)\n\ndiff --git a/t/t4202-log.sh b/t/t4202-log.sh\nindex 6d1411abea..b0122a1991 100755\n--- a/t/t4202-log.sh\n+++ b/t/t4202-log.sh\n@@ -344,6 +344,9 @@ test_expect_success 'log with various grep.patternType configurations & command-\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\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.11.0\n\n"},{"id":"319351","messageId":"20170511091829.5634-9-avarab@gmail.com","threadId":"45930","inReplyTo":"20170511091829.5634-1-avarab@gmail.com","subject":"[PATCH 08/29] grep: add tests for --threads=N and grep.threads","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2017-05-11T09:18:08Z","receivedAt":"2017-05-11T09:19:20Z","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\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.11.0\n\n"},{"id":"319352","messageId":"20170511091829.5634-10-avarab@gmail.com","threadId":"45930","inReplyTo":"20170511091829.5634-1-avarab@gmail.com","subject":"[PATCH 09/29] grep: amend submodule recursion test for regex engine testing","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2017-05-11T09:18:09Z","receivedAt":"2017-05-11T09:19:22Z","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..3c580b38ba 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)d\" --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)d\" --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.11.0\n\n"},{"id":"319353","messageId":"20170511091829.5634-11-avarab@gmail.com","threadId":"45930","inReplyTo":"20170511091829.5634-1-avarab@gmail.com","subject":"[PATCH 10/29] grep: add tests for grep pattern types being passed to submodules","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2017-05-11T09:18:10Z","receivedAt":"2017-05-11T09:19:26Z","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 3c580b38ba..ef658b7899 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.11.0\n\n"},{"id":"319354","messageId":"20170511091829.5634-8-avarab@gmail.com","threadId":"45930","inReplyTo":"20170511091829.5634-1-avarab@gmail.com","subject":"[PATCH 07/29] grep: change non-ASCII -i test to stop using --debug","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2017-05-11T09:18:07Z","receivedAt":"2017-05-11T09:19:29Z","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..969e7c0dda 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 --debug -i -F \"TILRAUN: Halló Heimur [abc]!\" file3\n '\n \n test_expect_success REGEX_LOCALE 'pickaxe -i on non-ascii' '\n-- \n2.11.0\n\n"},{"id":"319355","messageId":"20170511091829.5634-13-avarab@gmail.com","threadId":"45930","inReplyTo":"20170511091829.5634-1-avarab@gmail.com","subject":"[PATCH 12/29] grep: prepare for testing binary regexes containing rx metacharacters","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2017-05-11T09:18:12Z","receivedAt":"2017-05-11T09:19:31Z","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 6c1952eafa..1afba6cee9 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.11.0\n\n"},{"id":"319356","messageId":"20170511091829.5634-14-avarab@gmail.com","threadId":"45930","inReplyTo":"20170511091829.5634-1-avarab@gmail.com","subject":"[PATCH 13/29] grep: add tests to fix blind spots with \\0 patterns","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2017-05-11T09:18:13Z","receivedAt":"2017-05-11T09:19:35Z","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\nFurthermore, the kwset path is dependent on whether the the -i flag is\non, and whether the pattern has any non-ASCII characters, but none of\nthis was tested for.\n\nSee the a previous commit in this series (\"grep: add tests to fix\nblind spots with \\0 patterns\", 2017-04-21) for further details &\nrationale.\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 1afba6cee9..ba3db06501 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 $status = \"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 $status = \"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 status $status\" '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.11.0\n\n"},{"id":"319357","messageId":"20170511091829.5634-15-avarab@gmail.com","threadId":"45930","inReplyTo":"20170511091829.5634-1-avarab@gmail.com","subject":"[PATCH 14/29] 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-11T09:18:14Z","receivedAt":"2017-05-11T09:19:37Z","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 | 19 +++++++++++++++++--\n t/perf/run    | 11 +++++++++--\n 3 files changed, 29 insertions(+), 4 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..b3d95042a8 100644\n--- a/t/perf/README\n+++ b/t/perf/README\n@@ -60,8 +60,23 @@ 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-\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\n \tRepositories to copy for the performance tests.  The normal\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.11.0\n\n"},{"id":"319358","messageId":"20170511091829.5634-12-avarab@gmail.com","threadId":"45930","inReplyTo":"20170511091829.5634-1-avarab@gmail.com","subject":"[PATCH 11/29] grep: add a test helper function for less verbose -f \\0 tests","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2017-05-11T09:18:11Z","receivedAt":"2017-05-11T09:19:39Z","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..6c1952eafa 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+\tstatus=$1\n+\tflags=$2\n+\tpattern=$3\n+\tpattern_human=$(echo $pattern | sed 's/Q/<NUL>/g')\n+\n+\tif test $status = \"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 $status = \"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 status $status\" '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.11.0\n\n"},{"id":"319359","messageId":"20170511091829.5634-16-avarab@gmail.com","threadId":"45930","inReplyTo":"20170511091829.5634-1-avarab@gmail.com","subject":"[PATCH 15/29] perf: emit progress output when unpacking & building","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2017-05-11T09:18:15Z","receivedAt":"2017-05-11T09:19:45Z","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.11.0\n\n"},{"id":"319360","messageId":"20170511091829.5634-17-avarab@gmail.com","threadId":"45930","inReplyTo":"20170511091829.5634-1-avarab@gmail.com","subject":"[PATCH 16/29] perf: add a performance comparison test of grep -G, -E and -P","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2017-05-11T09:18:16Z","receivedAt":"2017-05-11T09:19:47Z","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    -------------------------------------------------------------\n    7820.1: basic grep how.to                      0.97(0.80+0.16)\n    7820.2: extended grep how.to                   1.03(0.81+0.19)\n    7820.3: perl grep how.to                       0.94(0.68+0.24)\n    7820.5: basic grep ^how to                     0.97(0.73+0.21)\n    7820.6: extended grep ^how to                  0.97(0.74+0.20)\n    7820.7: perl grep ^how to                      1.85(1.58+0.23)\n    7820.9: basic grep [how] to                    1.72(1.49+0.20)\n    7820.10: extended grep [how] to                1.67(1.42+0.23)\n    7820.11: perl grep [how] to                    1.81(1.56+0.22)\n    7820.13: basic grep \\(e.t[^ ]*\\|v.ry\\) rare    2.38(2.16+0.20)\n    7820.14: extended grep (e.t[^ ]*|v.ry) rare    2.42(2.16+0.22)\n    7820.15: perl grep (e.t[^ ]*|v.ry) rare        3.58(3.40+0.17)\n    7820.17: basic grep m\\(ú\\|u\\)ult.b\\(æ\\|y\\)te   1.04(0.77+0.24)\n    7820.18: extended grep m(ú|u)ult.b(æ|y)te      1.03(0.81+0.20)\n    7820.19: perl grep m(ú|u)ult.b(æ|y)te          1.23(0.98+0.24)\n\nSigned-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n---\n t/perf/p7820-grep-engines.sh | 35 +++++++++++++++++++++++++++++++++++\n 1 file changed, 35 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..c99979990e\n--- /dev/null\n+++ b/t/perf/p7820-grep-engines.sh\n@@ -0,0 +1,35 @@\n+#!/bin/sh\n+\n+test_description=\"Comparison of git-grep's regex engines\"\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\\)ult.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\ttest_perf \"$engine grep $pattern\" \"\n+\t\t\tgit -c grep.patternType=$engine grep -- '$pattern' >'out.$engine' || :\n+\t\t\"\n+\tdone\n+\n+\ttest_expect_success \"assert that all engines found the same for $pattern\" \"\n+\t\ttest_cmp 'out.basic' 'out.extended' &&\n+\t\ttest_cmp 'out.basic' 'out.perl'\n+\t\"\n+done\n+\n+test_done\n-- \n2.11.0\n\n"},{"id":"319361","messageId":"20170511091829.5634-19-avarab@gmail.com","threadId":"45930","inReplyTo":"20170511091829.5634-1-avarab@gmail.com","subject":"[PATCH 18/29] grep: catch a missing enum in switch statement","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2017-05-11T09:18:18Z","receivedAt":"2017-05-11T09:19:48Z","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.\n\nThus catching this at runtime is the least worst option. This won't\never trigger in practice, but if a new pattern type were to be added\nthis catches 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 | 6 ++++++\n 1 file changed, 6 insertions(+)\n\ndiff --git a/builtin/grep.c b/builtin/grep.c\nindex 3ffb5b4e81..1c0adb30f3 100644\n--- a/builtin/grep.c\n+++ b/builtin/grep.c\n@@ -495,6 +495,12 @@ 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\t/*\n+\t\t * -Wswitch doesn't catch this due to casting &\n+\t\t * -Wswitch-default is too noisy.\n+\t\t */\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.11.0\n\n"},{"id":"319362","messageId":"20170511091829.5634-18-avarab@gmail.com","threadId":"45930","inReplyTo":"20170511091829.5634-1-avarab@gmail.com","subject":"[PATCH 17/29] perf: add a performance comparison of fixed-string grep","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2017-05-11T09:18:17Z","receivedAt":"2017-05-11T09:19:52Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"Add a performance comparison test which compares both case-sensitive &\ncase-insensitive fixed-string grep, as well as non-ASCII\ncase-sensitive & case-insensitive grep.\n\nCurrently only the \"-i æ\" performance test doesn't go through the same\nkwset.[ch] codepath, see the \"Even when -F...\" comment in grep.c.\n\n    $ GIT_PERF_REPEAT_COUNT=10 GIT_PERF_LARGE_REPO=~/g/linux ./run p7821-grep-engines-fixed.sh\n    ----------------------------------------------\n    7821.1: fixed grep int         1.75(1.39+0.34)\n    7821.2: basic grep int         1.68(1.38+0.28)\n    7821.3: extended grep int      1.75(1.41+0.29)\n    7821.4: perl grep int          1.73(1.40+0.30)\n    7821.6: fixed grep -i int      1.94(1.54+0.35)\n    7821.7: basic grep -i int      1.92(1.57+0.32)\n    7821.8: extended grep -i int   1.90(1.54+0.30)\n    7821.9: perl grep -i int       1.91(1.53+0.36)\n    7821.11: fixed grep æ          1.35(1.14+0.18)\n    7821.12: basic grep æ          1.34(1.16+0.16)\n    7821.13: extended grep æ       1.33(1.15+0.17)\n    7821.14: perl grep æ           1.35(1.12+0.20)\n    7821.16: fixed grep -i æ       0.72(0.49+0.22)\n    7821.17: basic grep -i æ       0.74(0.49+0.21)\n    7821.18: extended grep -i æ    0.72(0.48+0.22)\n    7821.19: perl grep -i æ        0.71(0.44+0.23)\n\nI'm planning to make that not be the case, this performance test gives\na baseline for comparing performance before & after any such change.\n\nSee commit (\"perf: add a performance comparison test of grep -G, -E\nand -P\", 2017-04-19) for details on the machine the above test run was\nexecuted on.\n\nSigned-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n---\n t/perf/p7821-grep-engines-fixed.sh | 27 +++++++++++++++++++++++++++\n 1 file changed, 27 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..66a78d225d\n--- /dev/null\n+++ b/t/perf/p7821-grep-engines-fixed.sh\n@@ -0,0 +1,27 @@\n+#!/bin/sh\n+\n+test_description=\"Comparison of fixed string grep under git-grep's regex engines\"\n+\n+. ./perf-lib.sh\n+\n+test_perf_large_repo\n+test_checkout_worktree\n+\n+for args in 'int' '-i int' 'æ' '-i æ'\n+do\n+\tfor engine in fixed basic extended perl\n+\tdo\n+\t\ttest_perf \"$engine grep $args\" \"\n+\t\t\tgit -c grep.patternType=$engine grep $args >'out.$engine.$args' || :\n+\t\t\"\n+\tdone\n+\n+\ttest_expect_success \"assert that all engines found the same for $args\" \"\n+\t\ttest_cmp 'out.fixed.$args' 'out.basic.$args' &&\n+\t\ttest_cmp 'out.fixed.$args' 'out.extended.$args' &&\n+\t\ttest_cmp 'out.fixed.$args' 'out.extended.$args' &&\n+\t\ttest_cmp 'out.fixed.$args' 'out.perl.$args'\n+\t\"\n+done\n+\n+test_done\n-- \n2.11.0\n\n"},{"id":"319363","messageId":"20170511091829.5634-20-avarab@gmail.com","threadId":"45930","inReplyTo":"20170511091829.5634-1-avarab@gmail.com","subject":"[PATCH 19/29] grep: remove redundant regflags assignment under PCRE","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2017-05-11T09:18:19Z","receivedAt":"2017-05-11T09:19:54Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"Remove a redundant assignment to the \"regflags\" variable. This\nvariable is only used for POSIX regular expression matching, not when\nthe PCRE library is used.\n\nThis redundant assignment was added as a result of copy/paste\nprogramming in commit 84befcd0a4 (\"grep: add a grep.patternType\nconfiguration setting\", 2012-08-03). That commit modified already\nworking code in commit cca2c172e0 (\"git-grep: do not die upon -F/-P\nwhen grep.extendedRegexp is set.\", 2011-05-09) which didn't assign to\nregflags when under PCRE.\n\nRevert back to that behavior, more to reduce \"wait this is used under\nPCRE how?\" confusion when reading the code, than to to save ourselves\ntrivial CPU cycles by removing one assignment.\n\nSigned-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n---\n grep.c | 1 -\n 1 file changed, 1 deletion(-)\n\ndiff --git a/grep.c b/grep.c\nindex 47cee45067..59ae7809f2 100644\n--- a/grep.c\n+++ b/grep.c\n@@ -197,7 +197,6 @@ static void grep_set_pattern_type_option(enum grep_pattern_type pattern_type, st\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-- \n2.11.0\n\n"},{"id":"319364","messageId":"20170511091829.5634-21-avarab@gmail.com","threadId":"45930","inReplyTo":"20170511091829.5634-1-avarab@gmail.com","subject":"[PATCH 20/29] grep: remove redundant `regflags &= ~REG_EXTENDED` assignments","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2017-05-11T09:18:20Z","receivedAt":"2017-05-11T09:19:55Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"Remove redundant assignments to the \"regflags\" variable. There are no\ncode paths that have previously set the regflags to anything, and\ncertainly not to `|= REG_EXTENDED`.\n\nThis code gave the impression that it had to reset its environment,\nbut it doesn't. This dates back to the initial introduction of\ngit-grep in commit 5010cb5fcc (\"built-in \"git grep\"\", 2006-04-30).\n\nSigned-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n---\n grep.c | 5 +----\n 1 file changed, 1 insertion(+), 4 deletions(-)\n\ndiff --git a/grep.c b/grep.c\nindex 59ae7809f2..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,7 +190,6 @@ 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@@ -414,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.11.0\n\n"},{"id":"319365","messageId":"20170511091829.5634-22-avarab@gmail.com","threadId":"45930","inReplyTo":"20170511091829.5634-1-avarab@gmail.com","subject":"[PATCH 21/29] grep: factor test for \\0 in grep patterns into a function","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2017-05-11T09:18:21Z","receivedAt":"2017-05-11T09:19:59Z","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 limitation was never documented, and other some regular\nexpression engines are capable of compiling a pattern containing a\n\\0. Factoring this out makes a subsequent change which does that\nsmaller.\n\nSee a previous commit in this series (\"grep: add tests to fix blind\nspots with \\0 patterns\", 2017-04-21) for further details & rationale.\n\nSigned-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n---\n grep.c | 19 ++++++++++++-------\n 1 file changed, 12 insertions(+), 7 deletions(-)\n\ndiff --git a/grep.c b/grep.c\nindex bf6c2494fd..27de615209 100644\n--- a/grep.c\n+++ b/grep.c\n@@ -394,12 +394,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@@ -408,6 +402,17 @@ static int is_fixed(const char *s, size_t len)\n \treturn 1;\n }\n \n+static int has_null(const char *s, size_t len)\n+{\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 static void compile_fixed_regexp(struct grep_pat *p, struct grep_opt *opt)\n {\n \tstruct strbuf sb = STRBUF_INIT;\n@@ -451,7 +456,7 @@ 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 || has_null(p->pattern, p->patternlen) || is_fixed(p->pattern, p->patternlen))\n \t\tp->fixed = !icase || ascii_only;\n \telse\n \t\tp->fixed = 0;\n-- \n2.11.0\n\n"},{"id":"319366","messageId":"20170511091829.5634-23-avarab@gmail.com","threadId":"45930","inReplyTo":"20170511091829.5634-1-avarab@gmail.com","subject":"[PATCH 22/29] grep: change the internal PCRE macro names to be PCRE1","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2017-05-11T09:18:22Z","receivedAt":"2017-05-11T09:20:04Z","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 27de615209..0977cac723 100644\n--- a/grep.c\n+++ b/grep.c\n@@ -321,7 +321,7 @@ static NORETURN void compile_regexp_failed(const struct grep_pat *p,\n \tdie(\"%s'%s': %s\", where, p->pattern, error);\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@@ -373,7 +373,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@@ -388,7 +388,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 6abf1d1918..e5cfbcc36b 100644\n--- a/t/test-lib.sh\n+++ b/t/test-lib.sh\n@@ -1010,7 +1010,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.11.0\n\n"},{"id":"319367","messageId":"20170511091829.5634-24-avarab@gmail.com","threadId":"45930","inReplyTo":"20170511091829.5634-1-avarab@gmail.com","subject":"[PATCH 23/29] grep: change internal *pcre* variable & function names to be *pcre1*","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2017-05-11T09:18:23Z","receivedAt":"2017-05-11T09:20:06Z","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 0977cac723..4507765811 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@@ -322,7 +322,7 @@ static NORETURN void compile_regexp_failed(const struct grep_pat *p,\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@@ -330,23 +330,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@@ -354,7 +354,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@@ -367,25 +367,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@@ -476,8 +476,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@@ -833,8 +833,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@@ -913,8 +913,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.11.0\n\n"},{"id":"319368","messageId":"20170511091829.5634-25-avarab@gmail.com","threadId":"45930","inReplyTo":"20170511091829.5634-1-avarab@gmail.com","subject":"[PATCH 24/29] grep: move two functions to avoid forward declaration","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2017-05-11T09:18:24Z","receivedAt":"2017-05-11T09:20:10Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"Move the is_fixed() and has_null() functions which are currently only\nused in compile_regexp() earlier so they can be used in the PCRE\nfamily of functions in a later change.\n\nSigned-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n---\n grep.c | 46 +++++++++++++++++++++++-----------------------\n 1 file changed, 23 insertions(+), 23 deletions(-)\n\ndiff --git a/grep.c b/grep.c\nindex 4507765811..5c808f8971 100644\n--- a/grep.c\n+++ b/grep.c\n@@ -321,6 +321,29 @@ 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/* 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_LIBPCRE1\n static void compile_pcre1_regexp(struct grep_pat *p, const struct grep_opt *opt)\n {\n@@ -390,29 +413,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 int has_null(const char *s, size_t len)\n-{\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 static void compile_fixed_regexp(struct grep_pat *p, struct grep_opt *opt)\n {\n \tstruct strbuf sb = STRBUF_INIT;\n-- \n2.11.0\n\n"},{"id":"319369","messageId":"20170511091829.5634-26-avarab@gmail.com","threadId":"45930","inReplyTo":"20170511091829.5634-1-avarab@gmail.com","subject":"[PATCH 25/29] test-lib: add a PTHREADS prerequisite","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2017-05-11T09:18:25Z","receivedAt":"2017-05-11T09:20:12Z","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 e5cfbcc36b..ab92c0ebaa 100644\n--- a/t/test-lib.sh\n+++ b/t/test-lib.sh\n@@ -1009,6 +1009,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.11.0\n\n"},{"id":"319370","messageId":"20170511091829.5634-27-avarab@gmail.com","threadId":"45930","inReplyTo":"20170511091829.5634-1-avarab@gmail.com","subject":"[PATCH 26/29] pack-objects & index-pack: add test for --threads warning","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2017-05-11T09:18:26Z","receivedAt":"2017-05-11T09:20:20Z","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 | 34 ++++++++++++++++++++++++++++++++++\n 1 file changed, 34 insertions(+)\n\ndiff --git a/t/t5300-pack-object.sh b/t/t5300-pack-object.sh\nindex 43a672c345..1629fa80b0 100755\n--- a/t/t5300-pack-object.sh\n+++ b/t/t5300-pack-object.sh\n@@ -421,6 +421,40 @@ 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+\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+\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+\tgit -c pack.threads=2 pack-objects --stdout --all </dev/null >/dev/null 2>err &&\n+\tcat 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+\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.11.0\n\n"},{"id":"319371","messageId":"20170511091829.5634-29-avarab@gmail.com","threadId":"45930","inReplyTo":"20170511091829.5634-1-avarab@gmail.com","subject":"[PATCH 28/29] grep: given --threads with NO_PTHREADS=YesPlease, warn","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2017-05-11T09:18:28Z","receivedAt":"2017-05-11T09:20:21Z","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  | 11 +++++++++++\n t/t7810-grep.sh | 18 ++++++++++++++++++\n 2 files changed, 29 insertions(+)\n\ndiff --git a/builtin/grep.c b/builtin/grep.c\nindex 1c0adb30f3..f4e08dd2b6 100644\n--- a/builtin/grep.c\n+++ b/builtin/grep.c\n@@ -289,6 +289,15 @@ 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/* TRANSLATORS: %s is the configuration\n+\t\t\t   variable for tweaking threads, currently\n+\t\t\t   grep.threads */\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@@ -1233,6 +1242,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.11.0\n\n"},{"id":"319372","messageId":"20170511091829.5634-28-avarab@gmail.com","threadId":"45930","inReplyTo":"20170511091829.5634-1-avarab@gmail.com","subject":"[PATCH 27/29] pack-objects: fix buggy warning about threads","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2017-05-11T09:18:27Z","receivedAt":"2017-05-11T09:20:23Z","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 | 3 +--\n 2 files changed, 4 insertions(+), 3 deletions(-)\n\ndiff --git a/builtin/pack-objects.c b/builtin/pack-objects.c\nindex 0fe35d1b5a..f1baf05dfe 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 1629fa80b0..0ec25c4966 100755\n--- a/t/t5300-pack-object.sh\n+++ b/t/t5300-pack-object.sh\n@@ -445,8 +445,7 @@ test_expect_success !PTHREADS,C_LOCALE_OUTPUT 'pack-objects --threads=N or pack.\n \tgit -c pack.threads=2 pack-objects --stdout --all </dev/null >/dev/null 2>err &&\n \tcat err &&\n \tgrep ^warning: err >warnings &&\n-\ttest_line_count = 2 warnings &&\n-\tgrep -F \"no threads support, ignoring --threads\" err &&\n+\ttest_line_count = 1 warnings &&\n \tgrep -F \"no threads support, ignoring pack.threads\" err &&\n \tgit -c pack.threads=2 pack-objects --threads=4 --stdout --all </dev/null >/dev/null 2>err &&\n \tgrep ^warning: err >warnings &&\n-- \n2.11.0\n\n"},{"id":"319373","messageId":"20170511091829.5634-30-avarab@gmail.com","threadId":"45930","inReplyTo":"20170511091829.5634-1-avarab@gmail.com","subject":"[PATCH 29/29] grep: assert that threading is enabled when calling grep_{lock,unlock}","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2017-05-11T09:18:29Z","receivedAt":"2017-05-11T09:20:30Z","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 f4e08dd2b6..50e4bd2cd2 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.11.0\n\n"},{"id":"319435","messageId":"20170511183109.GC83655@google.com","threadId":"45930","inReplyTo":"20170511091829.5634-8-avarab@gmail.com","subject":"Re: [PATCH 07/29] grep: change non-ASCII -i test to stop using --debug","fromName":"Brandon Williams","fromEmail":"bmwill@google.com","sentAt":"2017-05-11T18:31:09Z","receivedAt":"2017-05-11T18:31:17Z","isPatch":true,"sender":{"key":"bwilliams.eng@gmail.com","avatar":null},"body":"On 05/11, Ævar Arnfjörð Bjarmason wrote:\n> Change a non-ASCII case-insensitive test case to stop using --debug,\n> and instead simply test for the expected results.\n> \n> The test coverage remains the same with this change, but the test\n> won't break due to internal refactoring.\n> \n> This test was added in commit 793dc676e0 (\"grep/icase: avoid kwsset\n> when -F is specified\", 2016-06-25). It was asserting that the regex\n> must be compiled with compile_fixed_regexp(), instead test for the\n> expected results, allowing the underlying implementation to change.\n> \n> Signed-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> \n> diff --git a/t/t7812-grep-icase-non-ascii.sh b/t/t7812-grep-icase-non-ascii.sh\n> index 04a61cb8e0..969e7c0dda 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 --debug -i -F \"TILRAUN: Halló Heimur [abc]!\" file3\n>  '\n\nYour commit message leads me to believe that you are reformatting the\ntests such that you don't use the '--dubug' flag yet this last line uses\nit.  Is this intentional?\n\n-- \nBrandon Williams\n"},{"id":"319436","messageId":"CACBZZX4mhhx3i2crQbON-_UEHMBRfw+FHQctiN9gU2pHQrvCng@mail.gmail.com","threadId":"45930","inReplyTo":"20170511183109.GC83655@google.com","subject":"Re: [PATCH 07/29] grep: change non-ASCII -i test to stop using --debug","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2017-05-11T18:35:58Z","receivedAt":"2017-05-11T18:36:24Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"On Thu, May 11, 2017 at 8:31 PM, Brandon Williams <bmwill@google.com> wrote:\n> On 05/11, Ęvar Arnfjörš Bjarmason wrote:\n>> Change a non-ASCII case-insensitive test case to stop using --debug,\n>> and instead simply test for the expected results.\n>>\n>> The test coverage remains the same with this change, but the test\n>> won't break due to internal refactoring.\n>>\n>> This test was added in commit 793dc676e0 (\"grep/icase: avoid kwsset\n>> when -F is specified\", 2016-06-25). It was asserting that the regex\n>> must be compiled with compile_fixed_regexp(), instead test for the\n>> expected results, allowing the underlying implementation to change.\n>>\n>> Signed-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>>\n>> diff --git a/t/t7812-grep-icase-non-ascii.sh b/t/t7812-grep-icase-non-ascii.sh\n>> index 04a61cb8e0..969e7c0dda 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>> -     git grep --debug -i -F \"TILRAUN: Halló Heimur!\"  2>&1 >/dev/null |\n>> -              grep fixed >debug1 &&\n>> -     test_write_lines \"fixed TILRAUN: Halló Heimur!\" >expect1 &&\n>> -     test_cmp expect1 debug1 &&\n>> -\n>> -     git grep --debug -i -F \"TILRAUN: HALLÓ HEIMUR!\"  2>&1 >/dev/null |\n>> -              grep fixed >debug2 &&\n>> -     test_write_lines \"fixed TILRAUN: HALLÓ HEIMUR!\" >expect2 &&\n>> -     test_cmp expect2 debug2\n>> +     git grep -i -F \"TILRAUN: Halló Heimur!\" &&\n>> +     git grep -i -F \"TILRAUN: HALLÓ HEIMUR!\"\n>>  '\n>>\n>>  test_expect_success REGEX_LOCALE 'grep string with regex, with -F' '\n>> -     test_write_lines \"^*TILR^AUN:.* \\\\Halló \\$He[]imur!\\$\" >file &&\n>> -\n>> -     git grep --debug -i -F \"^*TILR^AUN:.* \\\\Halló \\$He[]imur!\\$\" 2>&1 >/dev/null |\n>> -              grep fixed >debug1 &&\n>> -     test_write_lines \"fixed \\\\^*TILR^AUN:\\\\.\\\\* \\\\\\\\Halló \\$He\\\\[]imur!\\\\\\$\" >expect1 &&\n>> -     test_cmp expect1 debug1 &&\n>> -\n>> -     git grep --debug -i -F \"^*TILR^AUN:.* \\\\HALLÓ \\$HE[]IMUR!\\$\"  2>&1 >/dev/null |\n>> -              grep fixed >debug2 &&\n>> -     test_write_lines \"fixed \\\\^*TILR^AUN:\\\\.\\\\* \\\\\\\\HALLÓ \\$HE\\\\[]IMUR!\\\\\\$\" >expect2 &&\n>> -     test_cmp expect2 debug2\n>> +     test_write_lines \"TILRAUN: Halló Heimur [abc]!\" >file3 &&\n>> +     git add file3 &&\n>> +     git grep --debug -i -F \"TILRAUN: Halló Heimur [abc]!\" file3\n>>  '\n>\n> Your commit message leads me to believe that you are reformatting the\n> tests such that you don't use the '--dubug' flag yet this last line uses\n> it.  Is this intentional?\n\nNope, my mistake. Removing it is functionally equivalent (we discard\nstderr there). Will queue up a fix locally & send eventually in a v2.\n\nThanks a lot for looking this giant deluge of patches over.\n"},{"id":"319437","messageId":"20170511183640.GD83655@google.com","threadId":"45930","inReplyTo":"20170511091829.5634-9-avarab@gmail.com","subject":"Re: [PATCH 08/29] grep: add tests for --threads=N and grep.threads","fromName":"Brandon Williams","fromEmail":"bmwill@google.com","sentAt":"2017-05-11T18:36:40Z","receivedAt":"2017-05-11T18:36:58Z","isPatch":true,"sender":{"key":"bwilliams.eng@gmail.com","avatar":null},"body":"On 05/11, Ævar Arnfjörð Bjarmason wrote:\n> Add tests for --threads=N being supplied on the command-line, or when\n> grep.threads=N being supplied in the configuration.\n> \n> When the threading support was made run-time configurable in commit\n> 89f09dd34e (\"grep: add --threads=<num> option and grep.threads\n> configuration\", 2015-12-15) no tests were added for it.\n> \n> In developing a change to the grep code I was able to make\n> '--threads=1 <pat>` segfault, while the test suite still passed. This\n> change fixes that blind spot in the tests.\n> \n> In addition to asserting that asking for N threads shouldn't segfault,\n> test that the grep output given any N is the same.\n> \n> The choice to test only 1..10 as opposed to 1..8 or 1..16 or whatever\n> is arbitrary. Testing 1..1024 works locally for me (but gets\n> noticeably slower as more threads are spawned). Given the structure of\n> the code there's no reason to test an arbitrary number of threads,\n> only 0, 1 and >=2 are special modes of operation.\n> \n> Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n> ---\n>  t/t7810-grep.sh | 16 ++++++++++++++++\n>  1 file changed, 16 insertions(+)\n> \n> diff --git a/t/t7810-grep.sh b/t/t7810-grep.sh\n> index 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\nIs there a test condition to require PTHREADS?  Otherwise this might\nbreak if git is compiled with NO_PTHREADS.\n\n-- \nBrandon Williams\n"},{"id":"319445","messageId":"CACBZZX5gK__1dGZRkdb=Uj40igHSkpscaNVZvWpuuUFguynLfg@mail.gmail.com","threadId":"45930","inReplyTo":"20170511183640.GD83655@google.com","subject":"Re: [PATCH 08/29] grep: add tests for --threads=N and grep.threads","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2017-05-11T19:22:42Z","receivedAt":"2017-05-11T19:23:12Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"On Thu, May 11, 2017 at 8:36 PM, Brandon Williams <bmwill@google.com> wrote:\n> On 05/11, Ævar Arnfjörð Bjarmason wrote:\n>> Add tests for --threads=N being supplied on the command-line, or when\n>> grep.threads=N being supplied in the configuration.\n>>\n>> When the threading support was made run-time configurable in commit\n>> 89f09dd34e (\"grep: add --threads=<num> option and grep.threads\n>> configuration\", 2015-12-15) no tests were added for it.\n>>\n>> In developing a change to the grep code I was able to make\n>> '--threads=1 <pat>` segfault, while the test suite still passed. This\n>> change fixes that blind spot in the tests.\n>>\n>> In addition to asserting that asking for N threads shouldn't segfault,\n>> test that the grep output given any N is the same.\n>>\n>> The choice to test only 1..10 as opposed to 1..8 or 1..16 or whatever\n>> is arbitrary. Testing 1..1024 works locally for me (but gets\n>> noticeably slower as more threads are spawned). Given the structure of\n>> the code there's no reason to test an arbitrary number of threads,\n>> only 0, 1 and >=2 are special modes of operation.\n>>\n>> Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n>> ---\n>>  t/t7810-grep.sh | 16 ++++++++++++++++\n>>  1 file changed, 16 insertions(+)\n>>\n>> diff --git a/t/t7810-grep.sh b/t/t7810-grep.sh\n>> index 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>>       test_cmp expected actual\n>>  '\n>>\n>> +for threads in $(test_seq 0 10)\n>> +do\n>> +     test_expect_success \"grep --threads=$threads & -c grep.threads=$threads\" \"\n>> +             git grep --threads=$threads . >actual.$threads &&\n>> +             if test $threads -ge 1\n>> +             then\n>> +                     test_cmp actual.\\$(($threads - 1)) actual.$threads\n>> +             fi &&\n>> +             git -c grep.threads=$threads grep . >actual.$threads &&\n>> +             if test $threads -ge 1\n>> +             then\n>> +                     test_cmp actual.\\$(($threads - 1)) actual.$threads\n>> +             fi\n>> +     \"\n>> +done\n>> +\n>\n> Is there a test condition to require PTHREADS?  Otherwise this might\n> break if git is compiled with NO_PTHREADS.\n\nGood catch, this test works and I'll leave it like it is in a v2, but\nexplain it better in the commit message.\n\nWe just ignore --threads= with NO_PTHREADS, however later in this\nseries I introduce a warning for --threads when no threads are\nsupported, see \"grep: given --threads with NO_PTHREADS=YesPlease,\nwarn\".\n\nBut --threads=N still works, so this as a side-benefit tests that\n--threads=N still works with NO_PTHREADS, and tests don't fail if we\nspew to stderr.\n\nThe commit that adds the warning then tests for --threads getting a\nwarning with NO_THREADS=Y.\n"},{"id":"319449","messageId":"20170511200514.GE83655@google.com","threadId":"45930","inReplyTo":"CACBZZX4mhhx3i2crQbON-_UEHMBRfw+FHQctiN9gU2pHQrvCng@mail.gmail.com","subject":"Re: [PATCH 07/29] grep: change non-ASCII -i test to stop using --debug","fromName":"Brandon Williams","fromEmail":"bmwill@google.com","sentAt":"2017-05-11T20:05:14Z","receivedAt":"2017-05-11T20:05:21Z","isPatch":true,"sender":{"key":"bwilliams.eng@gmail.com","avatar":null},"body":"On 05/11, Ævar Arnfjörð Bjarmason wrote:\n> Thanks a lot for looking this giant deluge of patches over.\n\nNo problem, I'm no expert in some of the areas you're touching but\nat least I can catch little things like this :)\n\n-- \nBrandon Williams\n"},{"id":"319450","messageId":"20170511200804.GF83655@google.com","threadId":"45930","inReplyTo":"20170511091829.5634-19-avarab@gmail.com","subject":"Re: [PATCH 18/29] grep: catch a missing enum in switch statement","fromName":"Brandon Williams","fromEmail":"bmwill@google.com","sentAt":"2017-05-11T20:08:04Z","receivedAt":"2017-05-11T20:08:11Z","isPatch":true,"sender":{"key":"bwilliams.eng@gmail.com","avatar":null},"body":"On 05/11, Ævar Arnfjörð Bjarmason wrote:\n> Add a die(...) to a default case for the switch statement selecting\n> between grep pattern types under --recurse-submodules.\n> \n> Normally this would be caught by -Wswitch, but the grep_pattern_type\n> type is converted to int by going through parse_options(). Changing\n> the argument type passed to compile_submodule_options() won't work,\n> the value will just get coerced.\n> \n> Thus catching this at runtime is the least worst option. This won't\n> ever trigger in practice, but if a new pattern type were to be added\n> this catches an otherwise silent bug during development.\n> \n> See commit 0281e487fd (\"grep: optionally recurse into submodules\",\n> 2016-12-16) for the initial addition of this code.\n> \n> Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n> ---\n>  builtin/grep.c | 6 ++++++\n>  1 file changed, 6 insertions(+)\n> \n> diff --git a/builtin/grep.c b/builtin/grep.c\n> index 3ffb5b4e81..1c0adb30f3 100644\n> --- a/builtin/grep.c\n> +++ b/builtin/grep.c\n> @@ -495,6 +495,12 @@ 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\t/*\n> +\t\t * -Wswitch doesn't catch this due to casting &\n> +\t\t * -Wswitch-default is too noisy.\n> +\t\t */\n> +\t\tdie(\"BUG: Added a new grep pattern type without updating switch statement\");\n>  \t}\n\nThanks for adding this, as I got it wrong while developing this bit of\ncode.\n\n>  \n>  \tfor (pattern = opt->pattern_list; pattern != NULL;\n> -- \n> 2.11.0\n> \n\n-- \nBrandon Williams\n"},{"id":"319451","messageId":"20170511201015.GG83655@google.com","threadId":"45930","inReplyTo":"20170511091829.5634-23-avarab@gmail.com","subject":"Re: [PATCH 22/29] grep: change the internal PCRE macro names to be PCRE1","fromName":"Brandon Williams","fromEmail":"bmwill@google.com","sentAt":"2017-05-11T20:10:15Z","receivedAt":"2017-05-11T20:10:22Z","isPatch":true,"sender":{"key":"bwilliams.eng@gmail.com","avatar":null},"body":"On 05/11, Ævar Arnfjörð Bjarmason wrote:\n> Change the internal USE_LIBPCRE define, & build options flag to use a\n> naming convention ending in PCRE1, without changing the long-standing\n> USE_LIBPCRE Makefile flag which enables this code.\n> \n> This is for preparation for libpcre2 support where having things like\n> USE_LIBPCRE and USE_LIBPCRE2 in any more places than we absolutely\n> need to for backwards compatibility with old Makefile arguments would\n> be confusing.\n> \n> In some ways it would be better to change everything that now uses\n> USE_LIBPCRE to use USE_LIBPCRE1, and to make specifying\n> USE_LIBPCRE (or --with-pcre) an error. This would impose a one-time\n> burden on packagers of git to s/USE_LIBPCRE/USE_LIBPCRE1/ in their\n> build scripts.\n> \n> However I'd like to leave the door open to making\n> USE_LIBPCRE=YesPlease eventually mean USE_LIBPCRE2=YesPlease,\n> i.e. once PCRE v2 is ubiquitous enough that it makes sense to make it\n> the default.\n\nI know this isn't what you initially wanted but its probably the safest\noption.  Thanks.\n\n-- \nBrandon Williams\n"},{"id":"319452","messageId":"20170511201404.GH83655@google.com","threadId":"45930","inReplyTo":"20170511091829.5634-25-avarab@gmail.com","subject":"Re: [PATCH 24/29] grep: move two functions to avoid forward declaration","fromName":"Brandon Williams","fromEmail":"bmwill@google.com","sentAt":"2017-05-11T20:14:04Z","receivedAt":"2017-05-11T20:14:11Z","isPatch":true,"sender":{"key":"bwilliams.eng@gmail.com","avatar":null},"body":"On 05/11, Ævar Arnfjörð Bjarmason wrote:\n> Move the is_fixed() and has_null() functions which are currently only\n> used in compile_regexp() earlier so they can be used in the PCRE\n> family of functions in a later change.\n> \n> Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n> ---\n>  grep.c | 46 +++++++++++++++++++++++-----------------------\n>  1 file changed, 23 insertions(+), 23 deletions(-)\n> \n> diff --git a/grep.c b/grep.c\n> index 4507765811..5c808f8971 100644\n> --- a/grep.c\n> +++ b/grep.c\n> @@ -321,6 +321,29 @@ 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/* regcomp cannot accept patterns with NULs so when using it\n> +\t * we consider any pattern containing a NUL fixed.\n> +\t */\n\nSince you're already moving these functions, mind cleaning up the\ncomment to conform to our style guide?\n\n> +\tif (memchr(s, 0, len))\n> +\t\treturn 1;\n> +\n> +\treturn 0;\n> +}\n> +\n>  #ifdef USE_LIBPCRE1\n>  static void compile_pcre1_regexp(struct grep_pat *p, const struct grep_opt *opt)\n>  {\n> @@ -390,29 +413,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 int has_null(const char *s, size_t len)\n> -{\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>  static void compile_fixed_regexp(struct grep_pat *p, struct grep_opt *opt)\n>  {\n>  \tstruct strbuf sb = STRBUF_INIT;\n> -- \n> 2.11.0\n> \n\n-- \nBrandon Williams\n"},{"id":"319453","messageId":"20170511201517.GI83655@google.com","threadId":"45930","inReplyTo":"20170511091829.5634-22-avarab@gmail.com","subject":"Re: [PATCH 21/29] grep: factor test for \\0 in grep patterns into a function","fromName":"Brandon Williams","fromEmail":"bmwill@google.com","sentAt":"2017-05-11T20:15:17Z","receivedAt":"2017-05-11T20:15:25Z","isPatch":true,"sender":{"key":"bwilliams.eng@gmail.com","avatar":null},"body":"On 05/11, Ævar Arnfjörð Bjarmason wrote:\n> Factor the test for \\0 in grep patterns into a function. Since commit\n> 9eceddeec6 (\"Use kwset in grep\", 2011-08-21) any pattern containing a\n> \\0 is considered fixed as regcomp() can't handle it.\n> \n> This limitation was never documented, and other some regular\n> expression engines are capable of compiling a pattern containing a\n> \\0. Factoring this out makes a subsequent change which does that\n> smaller.\n> \n> See a previous commit in this series (\"grep: add tests to fix blind\n> spots with \\0 patterns\", 2017-04-21) for further details & rationale.\n> \n> Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n> ---\n>  grep.c | 19 ++++++++++++-------\n>  1 file changed, 12 insertions(+), 7 deletions(-)\n> \n> diff --git a/grep.c b/grep.c\n> index bf6c2494fd..27de615209 100644\n> --- a/grep.c\n> +++ b/grep.c\n> @@ -394,12 +394,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> @@ -408,6 +402,17 @@ static int is_fixed(const char *s, size_t len)\n>  \treturn 1;\n>  }\n>  \n> +static int has_null(const char *s, size_t len)\n> +{\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\nI commented on a later patch but really the comment should be fixed\nhere.  And why not simply move this to where you intend it to be at the\nend of the series now?\n\n> +\tif (memchr(s, 0, len))\n> +\t\treturn 1;\n> +\n> +\treturn 0;\n> +}\n> +\n>  static void compile_fixed_regexp(struct grep_pat *p, struct grep_opt *opt)\n>  {\n>  \tstruct strbuf sb = STRBUF_INIT;\n> @@ -451,7 +456,7 @@ 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 || has_null(p->pattern, p->patternlen) || is_fixed(p->pattern, p->patternlen))\n>  \t\tp->fixed = !icase || ascii_only;\n>  \telse\n>  \t\tp->fixed = 0;\n> -- \n> 2.11.0\n> \n\n-- \nBrandon Williams\n"},{"id":"319455","messageId":"20170511201742.GJ83655@google.com","threadId":"45930","inReplyTo":"20170511091829.5634-27-avarab@gmail.com","subject":"Re: [PATCH 26/29] pack-objects & index-pack: add test for --threads warning","fromName":"Brandon Williams","fromEmail":"bmwill@google.com","sentAt":"2017-05-11T20:17:42Z","receivedAt":"2017-05-11T20:17:49Z","isPatch":true,"sender":{"key":"bwilliams.eng@gmail.com","avatar":null},"body":"On 05/11, Ævar Arnfjörð Bjarmason wrote:\n> Add a test for the warning that's emitted when --threads or\n> pack.threads is provided under NO_PTHREADS=YesPlease. This uses the\n> new PTHREADS prerequisite.\n> \n> The assertion for C_LOCALE_OUTPUT in the latter test is currently\n> redundant, since unlike index-pack the pack-objects warnings aren't\n> i18n'd. However they might be changed to be i18n'd in the future, and\n> there's no harm in future-proofing the test.\n> \n> There's an existing bug in the implementation of pack-objects which\n> this test currently tests for as-is. Details about the bug & the fix\n> are included in a follow-up change.\n> \n> Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n> ---\n>  t/t5300-pack-object.sh | 34 ++++++++++++++++++++++++++++++++++\n>  1 file changed, 34 insertions(+)\n> \n> diff --git a/t/t5300-pack-object.sh b/t/t5300-pack-object.sh\n> index 43a672c345..1629fa80b0 100755\n> --- a/t/t5300-pack-object.sh\n> +++ b/t/t5300-pack-object.sh\n> @@ -421,6 +421,40 @@ 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> +\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> +\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> +\tgit -c pack.threads=2 pack-objects --stdout --all </dev/null >/dev/null 2>err &&\n> +\tcat 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> +\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\nSome of these tests you might want to rewrite using test_i18ncmp to\nensure that the messages match in other languages.  That is assuming\nthis error message is translated (which it should be).\n\n>  #\n>  # WARNING!\n>  #\n> -- \n> 2.11.0\n> \n\n-- \nBrandon Williams\n"},{"id":"319456","messageId":"CACBZZX4FqGzPn_knPMekP3fMChd_UJihYLmNcm-L-T_mPk4KMg@mail.gmail.com","threadId":"45930","inReplyTo":"20170511201404.GH83655@google.com","subject":"Re: [PATCH 24/29] grep: move two functions to avoid forward declaration","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2017-05-11T20:20:00Z","receivedAt":"2017-05-11T20:20:26Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"On Thu, May 11, 2017 at 10:14 PM, Brandon Williams <bmwill@google.com> wrote:\n> On 05/11, Ævar Arnfjörð Bjarmason wrote:\n>> Move the is_fixed() and has_null() functions which are currently only\n>> used in compile_regexp() earlier so they can be used in the PCRE\n>> family of functions in a later change.\n>>\n>> Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n>> ---\n>>  grep.c | 46 +++++++++++++++++++++++-----------------------\n>>  1 file changed, 23 insertions(+), 23 deletions(-)\n>>\n>> diff --git a/grep.c b/grep.c\n>> index 4507765811..5c808f8971 100644\n>> --- a/grep.c\n>> +++ b/grep.c\n>> @@ -321,6 +321,29 @@ static NORETURN void compile_regexp_failed(const struct grep_pat *p,\n>>       die(\"%s'%s': %s\", where, p->pattern, error);\n>>  }\n>>\n>> +static int is_fixed(const char *s, size_t len)\n>> +{\n>> +     size_t i;\n>> +\n>> +     for (i = 0; i < len; i++) {\n>> +             if (is_regex_special(s[i]))\n>> +                     return 0;\n>> +     }\n>> +\n>> +     return 1;\n>> +}\n>> +\n>> +static int has_null(const char *s, size_t len)\n>> +{\n>> +     /* regcomp cannot accept patterns with NULs so when using it\n>> +      * we consider any pattern containing a NUL fixed.\n>> +      */\n>\n> Since you're already moving these functions, mind cleaning up the\n> comment to conform to our style guide?\nWilldo.\n>> +     if (memchr(s, 0, len))\n>> +             return 1;\n>> +\n>> +     return 0;\n>> +}\n>> +\n>>  #ifdef USE_LIBPCRE1\n>>  static void compile_pcre1_regexp(struct grep_pat *p, const struct grep_opt *opt)\n>>  {\n>> @@ -390,29 +413,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>> -     size_t i;\n>> -\n>> -     for (i = 0; i < len; i++) {\n>> -             if (is_regex_special(s[i]))\n>> -                     return 0;\n>> -     }\n>> -\n>> -     return 1;\n>> -}\n>> -\n>> -static int has_null(const char *s, size_t len)\n>> -{\n>> -     /* regcomp cannot accept patterns with NULs so when using it\n>> -      * we consider any pattern containing a NUL fixed.\n>> -      */\n>> -     if (memchr(s, 0, len))\n>> -             return 1;\n>> -\n>> -     return 0;\n>> -}\n>> -\n>>  static void compile_fixed_regexp(struct grep_pat *p, struct grep_opt *opt)\n>>  {\n>>       struct strbuf sb = STRBUF_INIT;\n>> --\n>> 2.11.0\n>>\n>\n> --\n> Brandon Williams\n"},{"id":"319457","messageId":"20170511202131.GK83655@google.com","threadId":"45930","inReplyTo":"20170511091829.5634-29-avarab@gmail.com","subject":"Re: [PATCH 28/29] grep: given --threads with NO_PTHREADS=YesPlease, warn","fromName":"Brandon Williams","fromEmail":"bmwill@google.com","sentAt":"2017-05-11T20:21:31Z","receivedAt":"2017-05-11T20:21:46Z","isPatch":true,"sender":{"key":"bwilliams.eng@gmail.com","avatar":null},"body":"On 05/11, Ævar Arnfjörð Bjarmason wrote:\n> 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\n> under NO_PTHREADS=YesPlease.\n> \n> This is for consistency with the index-pack & pack-objects commands,\n> which also take a --threads option & are configurable via\n> pack.threads, and have long warned about the same under\n> NO_PTHREADS=YesPlease.\n> \n> Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n> ---\n>  builtin/grep.c  | 11 +++++++++++\n>  t/t7810-grep.sh | 18 ++++++++++++++++++\n>  2 files changed, 29 insertions(+)\n> \n> diff --git a/builtin/grep.c b/builtin/grep.c\n> index 1c0adb30f3..f4e08dd2b6 100644\n> --- a/builtin/grep.c\n> +++ b/builtin/grep.c\n> @@ -289,6 +289,15 @@ 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/* TRANSLATORS: %s is the configuration\n> +\t\t\t   variable for tweaking threads, currently\n> +\t\t\t   grep.threads */\n\nnit: this comment isn't formatted properly:\n  /*\n   * ... comment ...\n   */\n\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> @@ -1233,6 +1242,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>  \n> diff --git a/t/t7810-grep.sh b/t/t7810-grep.sh\n> index 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\nSame bit about doing the correct checks on the error strings to account\nfor translation.\n\n>  test_expect_success 'grep from a subdirectory to search wider area (1)' '\n>  \tmkdir -p s &&\n>  \t(\n> -- \n> 2.11.0\n> \n\n-- \nBrandon Williams\n"},{"id":"319458","messageId":"CACBZZX5tQKae=+fz-eofz+GwLt9mjtd26HrSt3zvjQGf++ve8w@mail.gmail.com","threadId":"45930","inReplyTo":"20170511201517.GI83655@google.com","subject":"Re: [PATCH 21/29] grep: factor test for \\0 in grep patterns into a function","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2017-05-11T20:22:03Z","receivedAt":"2017-05-11T20:22:29Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"On Thu, May 11, 2017 at 10:15 PM, Brandon Williams <bmwill@google.com> wrote:\n> On 05/11, Ævar Arnfjörð Bjarmason wrote:\n>> Factor the test for \\0 in grep patterns into a function. Since commit\n>> 9eceddeec6 (\"Use kwset in grep\", 2011-08-21) any pattern containing a\n>> \\0 is considered fixed as regcomp() can't handle it.\n>>\n>> This limitation was never documented, and other some regular\n>> expression engines are capable of compiling a pattern containing a\n>> \\0. Factoring this out makes a subsequent change which does that\n>> smaller.\n>>\n>> See a previous commit in this series (\"grep: add tests to fix blind\n>> spots with \\0 patterns\", 2017-04-21) for further details & rationale.\n>>\n>> Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n>> ---\n>>  grep.c | 19 ++++++++++++-------\n>>  1 file changed, 12 insertions(+), 7 deletions(-)\n>>\n>> diff --git a/grep.c b/grep.c\n>> index bf6c2494fd..27de615209 100644\n>> --- a/grep.c\n>> +++ b/grep.c\n>> @@ -394,12 +394,6 @@ static int is_fixed(const char *s, size_t len)\n>>  {\n>>       size_t i;\n>>\n>> -     /* regcomp cannot accept patterns with NULs so we\n>> -      * consider any pattern containing a NUL fixed.\n>> -      */\n>> -     if (memchr(s, 0, len))\n>> -             return 1;\n>> -\n>>       for (i = 0; i < len; i++) {\n>>               if (is_regex_special(s[i]))\n>>                       return 0;\n>> @@ -408,6 +402,17 @@ static int is_fixed(const char *s, size_t len)\n>>       return 1;\n>>  }\n>>\n>> +static int has_null(const char *s, size_t len)\n>> +{\n>> +     /* regcomp cannot accept patterns with NULs so when using it\n>> +      * we consider any pattern containing a NUL fixed.\n>> +      */\n>\n> I commented on a later patch but really the comment should be fixed\n> here.  And why not simply move this to where you intend it to be at the\n> end of the series now?\n\nJust losing the forest for the trees in rebasing this giant, willdo in\nv2, i.e. just make this a function in the right place in this change.\n\n>> +     if (memchr(s, 0, len))\n>> +             return 1;\n>> +\n>> +     return 0;\n>> +}\n>> +\n>>  static void compile_fixed_regexp(struct grep_pat *p, struct grep_opt *opt)\n>>  {\n>>       struct strbuf sb = STRBUF_INIT;\n>> @@ -451,7 +456,7 @@ static void compile_regexp(struct grep_pat *p, struct grep_opt *opt)\n>>        * simple string match using kws.  p->fixed tells us if we\n>>        * want to use kws.\n>>        */\n>> -     if (opt->fixed || is_fixed(p->pattern, p->patternlen))\n>> +     if (opt->fixed || has_null(p->pattern, p->patternlen) || is_fixed(p->pattern, p->patternlen))\n>>               p->fixed = !icase || ascii_only;\n>>       else\n>>               p->fixed = 0;\n>> --\n>> 2.11.0\n>>\n>\n> --\n> Brandon Williams\n"},{"id":"319460","messageId":"CACBZZX5-oDsMh08KNiEp8mDbCH06ROozc7sekts4BRsm-dTOwg@mail.gmail.com","threadId":"45930","inReplyTo":"20170511202131.GK83655@google.com","subject":"Re: [PATCH 28/29] grep: given --threads with NO_PTHREADS=YesPlease, warn","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2017-05-11T20:33:04Z","receivedAt":"2017-05-11T20:33:35Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"On Thu, May 11, 2017 at 10:21 PM, Brandon Williams <bmwill@google.com> wrote:\n> On 05/11, Ævar Arnfjörð Bjarmason wrote:\n>> 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\n>> under NO_PTHREADS=YesPlease.\n>>\n>> This is for consistency with the index-pack & pack-objects commands,\n>> which also take a --threads option & are configurable via\n>> pack.threads, and have long warned about the same under\n>> NO_PTHREADS=YesPlease.\n>>\n>> Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n>> ---\n>>  builtin/grep.c  | 11 +++++++++++\n>>  t/t7810-grep.sh | 18 ++++++++++++++++++\n>>  2 files changed, 29 insertions(+)\n>>\n>> diff --git a/builtin/grep.c b/builtin/grep.c\n>> index 1c0adb30f3..f4e08dd2b6 100644\n>> --- a/builtin/grep.c\n>> +++ b/builtin/grep.c\n>> @@ -289,6 +289,15 @@ static int grep_cmd_config(const char *var, const char *value, void *cb)\n>>               if (num_threads < 0)\n>>                       die(_(\"invalid number of threads specified (%d) for %s\"),\n>>                           num_threads, var);\n>> +#ifdef NO_PTHREADS\n>> +             else if (num_threads && num_threads != 1) {\n>> +                     /* TRANSLATORS: %s is the configuration\n>> +                        variable for tweaking threads, currently\n>> +                        grep.threads */\n>\n> nit: this comment isn't formatted properly:\n>   /*\n>    * ... comment ...\n>    */\n\nComments for translators use a different style, see cbcfd4e3ea (\"i18n:\nmention \"TRANSLATORS:\" marker in Documentation/CodingGuidelines\",\n2014-04-18). Otherwise the \"*\" gets interpolated into the string the\ntranslators see in their UI.\n\n>> +                     warning(_(\"no threads support, ignoring %s\"), var);\n>> +                     num_threads = 0;\n>> +             }\n>> +#endif\n>>       }\n>>\n>>       return st;\n>> @@ -1233,6 +1242,8 @@ int cmd_grep(int argc, const char **argv, const char *prefix)\n>>       else if (num_threads < 0)\n>>               die(_(\"invalid number of threads specified (%d)\"), num_threads);\n>>  #else\n>> +     if (num_threads)\n>> +             warning(_(\"no threads support, ignoring --threads\"));\n>>       num_threads = 0;\n>>  #endif\n>>\n>> diff --git a/t/t7810-grep.sh b/t/t7810-grep.sh\n>> index 561709ef6a..f106387820 100755\n>> --- a/t/t7810-grep.sh\n>> +++ b/t/t7810-grep.sh\n>> @@ -791,6 +791,24 @@ do\n>>       \"\n>>  done\n>>\n>> +test_expect_success !PTHREADS,C_LOCALE_OUTPUT 'grep --threads=N or pack.threads=N warns when no pthreads' '\n>> +     git grep --threads=2 Hello hello_world 2>err &&\n>> +     grep ^warning: err >warnings &&\n>> +     test_line_count = 1 warnings &&\n>> +     grep -F \"no threads support, ignoring --threads\" err &&\n>> +     git -c grep.threads=2 grep Hello hello_world 2>err &&\n>> +     grep ^warning: err >warnings &&\n>> +     test_line_count = 1 warnings &&\n>> +     grep -F \"no threads support, ignoring grep.threads\" err &&\n>> +     git -c grep.threads=2 grep --threads=4 Hello hello_world 2>err &&\n>> +     grep ^warning: err >warnings &&\n>> +     test_line_count = 2 warnings &&\n>> +     grep -F \"no threads support, ignoring --threads\" err &&\n>> +     grep -F \"no threads support, ignoring grep.threads\" err &&\n>> +     git -c grep.threads=0 grep --threads=0 Hello hello_world 2>err &&\n>> +     test_line_count = 0 err\n>> +'\n>> +\n>\n> Same bit about doing the correct checks on the error strings to account\n> for translation.\n\nDo you mean why not use test_i18ngrep? The test is guarded by\nC_LOCALE_OUTPUT which does the same thing, the whole thing is testing\noutput so no point in doing just parts of it IMO, unlike some other\ntests that just end in \"let's compare the output\" but actually test\nother stuff.\n\nI could e.g. test that there's something on stderr under poison, but\nno point in doing so.\n\n>>  test_expect_success 'grep from a subdirectory to search wider area (1)' '\n>>       mkdir -p s &&\n>>       (\n>> --\n>> 2.11.0\n>>\n>\n> --\n> Brandon Williams\n"},{"id":"319461","messageId":"CACBZZX5CPyo0yLUU+bGJyMNn1Ei2+B_MV8OxmVfa+=F=xdtGhQ@mail.gmail.com","threadId":"45930","inReplyTo":"20170511201742.GJ83655@google.com","subject":"Re: [PATCH 26/29] pack-objects & index-pack: add test for --threads warning","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2017-05-11T20:34:08Z","receivedAt":"2017-05-11T20:34:34Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"On Thu, May 11, 2017 at 10:17 PM, Brandon Williams <bmwill@google.com> wrote:\n> On 05/11, Ævar Arnfjörð Bjarmason wrote:\n>> Add a test for the warning that's emitted when --threads or\n>> pack.threads is provided under NO_PTHREADS=YesPlease. This uses the\n>> new PTHREADS prerequisite.\n>>\n>> The assertion for C_LOCALE_OUTPUT in the latter test is currently\n>> redundant, since unlike index-pack the pack-objects warnings aren't\n>> i18n'd. However they might be changed to be i18n'd in the future, and\n>> there's no harm in future-proofing the test.\n>>\n>> There's an existing bug in the implementation of pack-objects which\n>> this test currently tests for as-is. Details about the bug & the fix\n>> are included in a follow-up change.\n>>\n>> Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n>> ---\n>>  t/t5300-pack-object.sh | 34 ++++++++++++++++++++++++++++++++++\n>>  1 file changed, 34 insertions(+)\n>>\n>> diff --git a/t/t5300-pack-object.sh b/t/t5300-pack-object.sh\n>> index 43a672c345..1629fa80b0 100755\n>> --- a/t/t5300-pack-object.sh\n>> +++ b/t/t5300-pack-object.sh\n>> @@ -421,6 +421,40 @@ test_expect_success 'index-pack <pack> works in non-repo' '\n>>       test_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>> +     test_must_fail git index-pack --threads=2 2>err &&\n>> +     grep ^warning: err >warnings &&\n>> +     test_line_count = 1 warnings &&\n>> +     grep -F \"no threads support, ignoring --threads=2\" err &&\n>> +     test_must_fail git -c pack.threads=2 index-pack 2>err &&\n>> +     grep ^warning: err >warnings &&\n>> +     test_line_count = 1 warnings &&\n>> +     grep -F \"no threads support, ignoring pack.threads\" err &&\n>> +     test_must_fail git -c pack.threads=2 index-pack --threads=4 2>err &&\n>> +     grep ^warning: err >warnings &&\n>> +     test_line_count = 2 warnings &&\n>> +     grep -F \"no threads support, ignoring --threads=4\" err &&\n>> +     grep -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>> +     git pack-objects --threads=2 --stdout --all </dev/null >/dev/null 2>err &&\n>> +     grep ^warning: err >warnings &&\n>> +     test_line_count = 1 warnings &&\n>> +     grep -F \"no threads support, ignoring --threads\" err &&\n>> +     git -c pack.threads=2 pack-objects --stdout --all </dev/null >/dev/null 2>err &&\n>> +     cat err &&\n>> +     grep ^warning: err >warnings &&\n>> +     test_line_count = 2 warnings &&\n>> +     grep -F \"no threads support, ignoring --threads\" err &&\n>> +     grep -F \"no threads support, ignoring pack.threads\" err &&\n>> +     git -c pack.threads=2 pack-objects --threads=4 --stdout --all </dev/null >/dev/null 2>err &&\n>> +     grep ^warning: err >warnings &&\n>> +     test_line_count = 2 warnings &&\n>> +     grep -F \"no threads support, ignoring --threads\" err &&\n>> +     grep -F \"no threads support, ignoring pack.threads\" err\n>> +'\n>> +\n>\n> Some of these tests you might want to rewrite using test_i18ncmp to\n> ensure that the messages match in other languages.  That is assuming\n> this error message is translated (which it should be).\n\n[Mostly for my own notes so I see I covered this]\n\nCovered in a side-thread, the test is guarded by C_LOCALE_OUTPUT which\ndoes the same thing.\n\n>>  #\n>>  # WARNING!\n>>  #\n>> --\n>> 2.11.0\n>>\n>\n> --\n> Brandon Williams\n"},{"id":"319463","messageId":"CAGZ79kb_ueU8hArtA3yvYywvawnuD0RGQBtm1=OEuQi2L0rjmA@mail.gmail.com","threadId":"45930","inReplyTo":"20170511200804.GF83655@google.com","subject":"Re: [PATCH 18/29] grep: catch a missing enum in switch statement","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2017-05-11T20:40:43Z","receivedAt":"2017-05-11T20:40:49Z","isPatch":true,"sender":{"key":"stefanbeller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/455868?v=4"},"body":"On Thu, May 11, 2017 at 1:08 PM, Brandon Williams <bmwill@google.com> wrote:\n> On 05/11, Ævar Arnfjörð Bjarmason wrote:\n>> Add a die(...) to a default case for the switch statement selecting\n>> between grep pattern types under --recurse-submodules.\n>>\n>> Normally this would be caught by -Wswitch, but the grep_pattern_type\n>> type is converted to int by going through parse_options(). Changing\n>> the argument type passed to compile_submodule_options() won't work,\n>> the value will just get coerced.\n>>\n>> Thus catching this at runtime is the least worst option. This won't\n>> ever trigger in practice, but if a new pattern type were to be added\n>> this catches an otherwise silent bug during development.\n>>\n>> See commit 0281e487fd (\"grep: optionally recurse into submodules\",\n>> 2016-12-16) for the initial addition of this code.\n>>\n>> Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n>> ---\n>>  builtin/grep.c | 6 ++++++\n>>  1 file changed, 6 insertions(+)\n>>\n>> diff --git a/builtin/grep.c b/builtin/grep.c\n>> index 3ffb5b4e81..1c0adb30f3 100644\n>> --- a/builtin/grep.c\n>> +++ b/builtin/grep.c\n>> @@ -495,6 +495,12 @@ static void compile_submodule_options(const struct grep_opt *opt,\n>>               break;\n>>       case GREP_PATTERN_TYPE_UNSPECIFIED:\n>>               break;\n>> +     default:\n>> +             /*\n>> +              * -Wswitch doesn't catch this due to casting &\n>> +              * -Wswitch-default is too noisy.\n>> +              */\n>> +             die(\"BUG: Added a new grep pattern type without updating switch statement\");\n\nI am not sure if the comment is of enough value for the used screen\nreal estate value.\nPeople interested in the existence of the default would just use\nblame/log to find out.\n\nThanks,\nStefan\n"},{"id":"319464","messageId":"20170511204334.GM83655@google.com","threadId":"45930","inReplyTo":"CACBZZX5-oDsMh08KNiEp8mDbCH06ROozc7sekts4BRsm-dTOwg@mail.gmail.com","subject":"Re: [PATCH 28/29] grep: given --threads with NO_PTHREADS=YesPlease, warn","fromName":"Brandon Williams","fromEmail":"bmwill@google.com","sentAt":"2017-05-11T20:43:34Z","receivedAt":"2017-05-11T20:43:42Z","isPatch":true,"sender":{"key":"bwilliams.eng@gmail.com","avatar":null},"body":"On 05/11, Ævar Arnfjörð Bjarmason wrote:\n> On Thu, May 11, 2017 at 10:21 PM, Brandon Williams <bmwill@google.com> wrote:\n> > On 05/11, Ævar Arnfjörð Bjarmason wrote:\n> >> 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\n> >> under NO_PTHREADS=YesPlease.\n> >>\n> >> This is for consistency with the index-pack & pack-objects commands,\n> >> which also take a --threads option & are configurable via\n> >> pack.threads, and have long warned about the same under\n> >> NO_PTHREADS=YesPlease.\n> >>\n> >> Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n> >> ---\n> >>  builtin/grep.c  | 11 +++++++++++\n> >>  t/t7810-grep.sh | 18 ++++++++++++++++++\n> >>  2 files changed, 29 insertions(+)\n> >>\n> >> diff --git a/builtin/grep.c b/builtin/grep.c\n> >> index 1c0adb30f3..f4e08dd2b6 100644\n> >> --- a/builtin/grep.c\n> >> +++ b/builtin/grep.c\n> >> @@ -289,6 +289,15 @@ static int grep_cmd_config(const char *var, const char *value, void *cb)\n> >>               if (num_threads < 0)\n> >>                       die(_(\"invalid number of threads specified (%d) for %s\"),\n> >>                           num_threads, var);\n> >> +#ifdef NO_PTHREADS\n> >> +             else if (num_threads && num_threads != 1) {\n> >> +                     /* TRANSLATORS: %s is the configuration\n> >> +                        variable for tweaking threads, currently\n> >> +                        grep.threads */\n> >\n> > nit: this comment isn't formatted properly:\n> >   /*\n> >    * ... comment ...\n> >    */\n> \n> Comments for translators use a different style, see cbcfd4e3ea (\"i18n:\n> mention \"TRANSLATORS:\" marker in Documentation/CodingGuidelines\",\n> 2014-04-18). Otherwise the \"*\" gets interpolated into the string the\n> translators see in their UI.\n> \n\nAh got it, I wasn't aware of that.\n\n> >> +                     warning(_(\"no threads support, ignoring %s\"), var);\n> >> +                     num_threads = 0;\n> >> +             }\n> >> +#endif\n> >>       }\n> >>\n> >>       return st;\n> >> @@ -1233,6 +1242,8 @@ int cmd_grep(int argc, const char **argv, const char *prefix)\n> >>       else if (num_threads < 0)\n> >>               die(_(\"invalid number of threads specified (%d)\"), num_threads);\n> >>  #else\n> >> +     if (num_threads)\n> >> +             warning(_(\"no threads support, ignoring --threads\"));\n> >>       num_threads = 0;\n> >>  #endif\n> >>\n> >> diff --git a/t/t7810-grep.sh b/t/t7810-grep.sh\n> >> index 561709ef6a..f106387820 100755\n> >> --- a/t/t7810-grep.sh\n> >> +++ b/t/t7810-grep.sh\n> >> @@ -791,6 +791,24 @@ do\n> >>       \"\n> >>  done\n> >>\n> >> +test_expect_success !PTHREADS,C_LOCALE_OUTPUT 'grep --threads=N or pack.threads=N warns when no pthreads' '\n> >> +     git grep --threads=2 Hello hello_world 2>err &&\n> >> +     grep ^warning: err >warnings &&\n> >> +     test_line_count = 1 warnings &&\n> >> +     grep -F \"no threads support, ignoring --threads\" err &&\n> >> +     git -c grep.threads=2 grep Hello hello_world 2>err &&\n> >> +     grep ^warning: err >warnings &&\n> >> +     test_line_count = 1 warnings &&\n> >> +     grep -F \"no threads support, ignoring grep.threads\" err &&\n> >> +     git -c grep.threads=2 grep --threads=4 Hello hello_world 2>err &&\n> >> +     grep ^warning: err >warnings &&\n> >> +     test_line_count = 2 warnings &&\n> >> +     grep -F \"no threads support, ignoring --threads\" err &&\n> >> +     grep -F \"no threads support, ignoring grep.threads\" err &&\n> >> +     git -c grep.threads=0 grep --threads=0 Hello hello_world 2>err &&\n> >> +     test_line_count = 0 err\n> >> +'\n> >> +\n> >\n> > Same bit about doing the correct checks on the error strings to account\n> > for translation.\n> \n> Do you mean why not use test_i18ngrep? The test is guarded by\n> C_LOCALE_OUTPUT which does the same thing, the whole thing is testing\n> output so no point in doing just parts of it IMO, unlike some other\n> tests that just end in \"let's compare the output\" but actually test\n> other stuff.\n> \n> I could e.g. test that there's something on stderr under poison, but\n> no point in doing so.\n\nFair enough, and I didn't notice the C_LOCALE_OUTPUT.\n\n> \n> >>  test_expect_success 'grep from a subdirectory to search wider area (1)' '\n> >>       mkdir -p s &&\n> >>       (\n> >> --\n> >> 2.11.0\n> >>\n> >\n> > --\n> > Brandon Williams\n\n-- \nBrandon Williams\n"},{"id":"319465","messageId":"CACBZZX6-jQA3Dn1rzVcXq6=wF-VkXELQqLwEsJYH=ede1_3syw@mail.gmail.com","threadId":"45930","inReplyTo":"CAGZ79kb_ueU8hArtA3yvYywvawnuD0RGQBtm1=OEuQi2L0rjmA@mail.gmail.com","subject":"Re: [PATCH 18/29] grep: catch a missing enum in switch statement","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2017-05-11T20:50:30Z","receivedAt":"2017-05-11T20:50:57Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"On Thu, May 11, 2017 at 10:40 PM, Stefan Beller <sbeller@google.com> wrote:\n> On Thu, May 11, 2017 at 1:08 PM, Brandon Williams <bmwill@google.com> wrote:\n>> On 05/11, Ævar Arnfjörð Bjarmason wrote:\n>>> Add a die(...) to a default case for the switch statement selecting\n>>> between grep pattern types under --recurse-submodules.\n>>>\n>>> Normally this would be caught by -Wswitch, but the grep_pattern_type\n>>> type is converted to int by going through parse_options(). Changing\n>>> the argument type passed to compile_submodule_options() won't work,\n>>> the value will just get coerced.\n>>>\n>>> Thus catching this at runtime is the least worst option. This won't\n>>> ever trigger in practice, but if a new pattern type were to be added\n>>> this catches an otherwise silent bug during development.\n>>>\n>>> See commit 0281e487fd (\"grep: optionally recurse into submodules\",\n>>> 2016-12-16) for the initial addition of this code.\n>>>\n>>> Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n>>> ---\n>>>  builtin/grep.c | 6 ++++++\n>>>  1 file changed, 6 insertions(+)\n>>>\n>>> diff --git a/builtin/grep.c b/builtin/grep.c\n>>> index 3ffb5b4e81..1c0adb30f3 100644\n>>> --- a/builtin/grep.c\n>>> +++ b/builtin/grep.c\n>>> @@ -495,6 +495,12 @@ static void compile_submodule_options(const struct grep_opt *opt,\n>>>               break;\n>>>       case GREP_PATTERN_TYPE_UNSPECIFIED:\n>>>               break;\n>>> +     default:\n>>> +             /*\n>>> +              * -Wswitch doesn't catch this due to casting &\n>>> +              * -Wswitch-default is too noisy.\n>>> +              */\n>>> +             die(\"BUG: Added a new grep pattern type without updating switch statement\");\n>\n> I am not sure if the comment is of enough value for the used screen\n> real estate value.\n> People interested in the existence of the default would just use\n> blame/log to find out.\n\nThanks, I was on the fence about it, will remove it (and add the\nmention of -Wswitch-default to the commit message).\n"},{"id":"319469","messageId":"20170511212012.6782-1-avarab@gmail.com","threadId":"45930","inReplyTo":"20170511204334.GM83655@google.com","subject":"[PATCH] C style: use standard style for \"TRANSLATORS\" comments","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2017-05-11T21:20:12Z","receivedAt":"2017-05-11T21:20:30Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"Change all the \"TRANSLATORS: [...]\" comments in the C code to use the\nregular Git coding style, and amend the style guide so that the\nexample there uses that style.\n\nThis custom style was necessary back in 2010 when the gettext support\nwas initially added, and was subsequently documented in commit\ncbcfd4e3ea (\"i18n: mention \"TRANSLATORS:\" marker in\nDocumentation/CodingGuidelines\", 2014-04-18).\n\nGNU xgettext hasn't had the parsing limitation that necessitated this\nexception for almost 3 years. Since its 0.19 release on 2014-06-02\nit's been able to recognize TRANSLATOR comments in the standard Git\ncomment syntax[1].\n\nUsually we'd like to keep compatibility with software that's that\nyoung, but in this case literally the only person who needs to be\nusing a gettext newer than 3 years old is Jiang Xin (the only person\nwho runs & commits \"make pot\" results), so I think in this case we can\nmake an exception.\n\nThis xgettext parsing feature was added after a thread on the Git\nmailing list[2] which continued on the bug-gettext[3] list, but we\nnever subsequently changed our style & styleguide, do so.\n\nThere are already longstanding changes in git that use the standard\ncomment style & have their TRANSLATORS comments extracted properly\nwithout getting the literal \"*\"'s mixed up in the text, as would\nhappen before xgettext 0.19.\n\nCommit 7ff2683253 (\"builtin-am: implement -i/--interactive\",\n2015-08-04) added one such comment, which in commit df0617bfa7 (\"l10n:\ngit.pot: v2.6.0 round 1 (123 new, 41 removed)\", 2015-09-05) got picked\nup in the po/git.pot file with the right format, showing that Jiang\nalready runs a modern xgettext.\n\nThe xgettext parser does not handle the sort of non-standard comment\nstyle that I'm amending here in sequencer.c, but that isn't standard\nGit comment syntax anyway. With this change to sequencer.c & \"make\npot\" the comment in the pot file is now correct:\n\n     #. TRANSLATORS: %s will be \"revert\", \"cherry-pick\" or\n    -#. * \"rebase -i\".\n    +#. \"rebase -i\".\n\n1. http://git.savannah.gnu.org/cgit/gettext.git/commit/?id=10af7fe6bd\n2. <2ce9ec406501d112e032c8208417f8100bed04c6.1397712142.git.worldhello.net@gmail.com>\n   (https://public-inbox.org/git/2ce9ec406501d112e032c8208417f8100bed04c6.1397712142.git.worldhello.net@gmail.com/)\n3. https://lists.gnu.org/archive/html/bug-gettext/2014-04/msg00016.html\n\nSigned-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n---\n\nOn Thu, May 11, 2017 at 10:43 PM, Brandon Williams <bmwill@google.com> wrote:\n> On 05/11, Ævar Arnfjörð Bjarmason wrote:\n>> On Thu, May 11, 2017 at 10:21 PM, Brandon Williams <bmwill@google.com> wrote:\n>> > On 05/11, Ævar Arnfjörð Bjarmason wrote:\n>> >> [...]\n>> >> +#ifdef NO_PTHREADS\n>> >> +             else if (num_threads && num_threads != 1) {\n>> >> +                     /* TRANSLATORS: %s is the configuration\n>> >> +                        variable for tweaking threads, currently\n>> >> +                        grep.threads */\n>> >\n>> > nit: this comment isn't formatted properly:\n>> >   /*\n>> >    * ... comment ...\n>> >    */\n>>\n>> Comments for translators use a different style, see cbcfd4e3ea (\"i18n:\n>> mention \"TRANSLATORS:\" marker in Documentation/CodingGuidelines\",\n>> 2014-04-18). Otherwise the \"*\" gets interpolated into the string the\n>> translators see in their UI.\n>>\n>\n> Ah got it, I wasn't aware of that.\n\nAs it turns out this is just something we've been cargo-culting for\nyears for no reason. Will fix this comment in my v2, but first let's\ndo this.\n\n Documentation/CodingGuidelines | 10 +++++-----\n bisect.c                       |  6 ++++--\n builtin/blame.c                | 15 +++++++++------\n builtin/notes.c                |  6 ++++--\n builtin/remote.c               |  7 +++++--\n notes-utils.c                  |  7 +++++--\n parse-options.c                |  6 ++++--\n ref-filter.c                   | 12 ++++++++----\n sequencer.c                    |  3 ++-\n 9 files changed, 46 insertions(+), 26 deletions(-)\n\ndiff --git a/Documentation/CodingGuidelines b/Documentation/CodingGuidelines\nindex a4191aa388..9fd7383819 100644\n--- a/Documentation/CodingGuidelines\n+++ b/Documentation/CodingGuidelines\n@@ -256,12 +256,12 @@ For C programs:\n \n    Note however that a comment that explains a translatable string to\n    translators uses a convention of starting with a magic token\n-   \"TRANSLATORS: \" immediately after the opening delimiter, even when\n-   it spans multiple lines.  We do not add an asterisk at the beginning\n-   of each line, either.  E.g.\n+   \"TRANSLATORS: \", e.g.\n \n-\t/* TRANSLATORS: here is a comment that explains the string\n-\t   to be translated, that follows immediately after it */\n+\t/*\n+\t * TRANSLATORS: here is a comment that explains the string to\n+\t * be translated, that follows immediately after it.\n+\t */\n \t_(\"Here is a translatable string explained by the above.\");\n \n  - Double negation is often harder to understand than no negation\ndiff --git a/bisect.c b/bisect.c\nindex 08c9fb7266..c5d5a2b64b 100644\n--- a/bisect.c\n+++ b/bisect.c\n@@ -995,8 +995,10 @@ int bisect_next_all(const char *prefix, int no_checkout)\n \n \tsteps_msg = xstrfmt(Q_(\"(roughly %d step)\", \"(roughly %d steps)\",\n \t\t  steps), steps);\n-\t/* TRANSLATORS: the last %s will be replaced with\n-\t   \"(roughly %d steps)\" translation */\n+\t/*\n+\t * TRANSLATORS: the last %s will be replaced with \"(roughly %d\n+\t * steps)\" translation.\n+\t */\n \tprintf(Q_(\"Bisecting: %d revision left to test after this %s\\n\",\n \t\t  \"Bisecting: %d revisions left to test after this %s\\n\",\n \t\t  nr), nr, steps_msg);\ndiff --git a/builtin/blame.c b/builtin/blame.c\nindex 07506a3e45..ca9ebe40e7 100644\n--- a/builtin/blame.c\n+++ b/builtin/blame.c\n@@ -2688,12 +2688,15 @@ int cmd_blame(int argc, const char **argv, const char *prefix)\n \t\tblame_date_width = sizeof(\"2006-10-19\");\n \t\tbreak;\n \tcase DATE_RELATIVE:\n-\t\t/* TRANSLATORS: This string is used to tell us the maximum\n-\t\t   display width for a relative timestamp in \"git blame\"\n-\t\t   output.  For C locale, \"4 years, 11 months ago\", which\n-\t\t   takes 22 places, is the longest among various forms of\n-\t\t   relative timestamps, but your language may need more or\n-\t\t   fewer display columns. */\n+\t\t/*\n+\t\t * TRANSLATORS: This string is used to tell us the\n+\t\t * maximum display width for a relative timestamp in\n+\t\t * \"git blame\" output.  For C locale, \"4 years, 11\n+\t\t * months ago\", which takes 22 places, is the longest\n+\t\t * among various forms of relative timestamps, but\n+\t\t * your language may need more or fewer display\n+\t\t * columns.\n+\t\t */\n \t\tblame_date_width = utf8_strwidth(_(\"4 years, 11 months ago\")) + 1; /* add the null */\n \t\tbreak;\n \tcase DATE_NORMAL:\ndiff --git a/builtin/notes.c b/builtin/notes.c\nindex 7b891471c4..fb856e53b6 100644\n--- a/builtin/notes.c\n+++ b/builtin/notes.c\n@@ -340,8 +340,10 @@ static struct notes_tree *init_notes_check(const char *subcommand,\n \n \tref = (flags & NOTES_INIT_WRITABLE) ? t->update_ref : t->ref;\n \tif (!starts_with(ref, \"refs/notes/\"))\n-\t\t/* TRANSLATORS: the first %s will be replaced by a\n-\t\t   git notes command: 'add', 'merge', 'remove', etc.*/\n+\t\t/*\n+\t\t * TRANSLATORS: the first %s will be replaced by a git\n+\t\t * notes command: 'add', 'merge', 'remove', etc.\n+\t\t */\n \t\tdie(_(\"refusing to %s notes in %s (outside of refs/notes/)\"),\n \t\t    subcommand, ref);\n \treturn t;\ndiff --git a/builtin/remote.c b/builtin/remote.c\nindex addf97ad29..9054e2858e 100644\n--- a/builtin/remote.c\n+++ b/builtin/remote.c\n@@ -1151,8 +1151,11 @@ static int show(int argc, const char **argv)\n \t\t\turl_nr = states.remote->url_nr;\n \t\t}\n \t\tfor (i = 0; i < url_nr; i++)\n-\t\t\t/* TRANSLATORS: the colon ':' should align with\n-\t\t\t   the one in \"  Fetch URL: %s\" translation */\n+\t\t\t/*\n+\t\t\t * TRANSLATORS: the colon ':' should align\n+\t\t\t * with the one in \" Fetch URL: %s\"\n+\t\t\t * translation.\n+\t\t\t */\n \t\t\tprintf_ln(_(\"  Push  URL: %s\"), url[i]);\n \t\tif (!i)\n \t\t\tprintf_ln(_(\"  Push  URL: %s\"), _(\"(no URL)\"));\ndiff --git a/notes-utils.c b/notes-utils.c\nindex 24a33616a4..8f9ad7d1f8 100644\n--- a/notes-utils.c\n+++ b/notes-utils.c\n@@ -132,8 +132,11 @@ struct notes_rewrite_cfg *init_copy_notes_for_rewrite(const char *cmd)\n \t\tc->mode_from_env = 1;\n \t\tc->combine = parse_combine_notes_fn(rewrite_mode_env);\n \t\tif (!c->combine)\n-\t\t\t/* TRANSLATORS: The first %s is the name of the\n-\t\t\t   environment variable, the second %s is its value */\n+\t\t\t/*\n+\t\t\t * TRANSLATORS: The first %s is the name of\n+\t\t\t * the environment variable, the second %s is\n+\t\t\t * its value.\n+\t\t\t */\n \t\t\terror(_(\"Bad %s value: '%s'\"), GIT_NOTES_REWRITE_MODE_ENVIRONMENT,\n \t\t\t\t\trewrite_mode_env);\n \t}\ndiff --git a/parse-options.c b/parse-options.c\nindex a23a1e67f0..e5ad34a2c3 100644\n--- a/parse-options.c\n+++ b/parse-options.c\n@@ -589,8 +589,10 @@ static int usage_with_options_internal(struct parse_opt_ctx_t *ctx,\n \n \tfprintf_ln(outfile, _(\"usage: %s\"), _(*usagestr++));\n \twhile (*usagestr && **usagestr)\n-\t\t/* TRANSLATORS: the colon here should align with the\n-\t\t   one in \"usage: %s\" translation */\n+\t\t/*\n+\t\t * TRANSLATORS: the colon here should align with the\n+\t\t * one in \"usage: %s\" translation.\n+\t\t */\n \t\tfprintf_ln(outfile, _(\"   or: %s\"), _(*usagestr++));\n \twhile (*usagestr) {\n \t\tif (**usagestr)\ndiff --git a/ref-filter.c b/ref-filter.c\nindex 3a640448fd..5632841753 100644\n--- a/ref-filter.c\n+++ b/ref-filter.c\n@@ -1251,13 +1251,17 @@ char *get_head_description(void)\n \t\t\t    state.branch);\n \telse if (state.detached_from) {\n \t\tif (state.detached_at)\n-\t\t\t/* TRANSLATORS: make sure this matches\n-\t\t\t   \"HEAD detached at \" in wt-status.c */\n+\t\t\t/*\n+\t\t\t * TRANSLATORS: make sure this matches \"HEAD\n+\t\t\t * detached at \" in wt-status.c\n+\t\t\t */\n \t\t\tstrbuf_addf(&desc, _(\"(HEAD detached at %s)\"),\n \t\t\t\tstate.detached_from);\n \t\telse\n-\t\t\t/* TRANSLATORS: make sure this matches\n-\t\t\t   \"HEAD detached from \" in wt-status.c */\n+\t\t\t/*\n+\t\t\t * TRANSLATORS: make sure this matches \"HEAD\n+\t\t\t * detached from \" in wt-status.c\n+\t\t\t */\n \t\t\tstrbuf_addf(&desc, _(\"(HEAD detached from %s)\"),\n \t\t\t\tstate.detached_from);\n \t}\ndiff --git a/sequencer.c b/sequencer.c\nindex 10c3b4ff81..b77f359ca2 100644\n--- a/sequencer.c\n+++ b/sequencer.c\n@@ -464,7 +464,8 @@ static int do_recursive_merge(struct commit *base, struct commit *next,\n \n \tif (active_cache_changed &&\n \t    write_locked_index(&the_index, &index_lock, COMMIT_LOCK))\n-\t\t/* TRANSLATORS: %s will be \"revert\", \"cherry-pick\" or\n+\t\t/*\n+\t\t * TRANSLATORS: %s will be \"revert\", \"cherry-pick\" or\n \t\t * \"rebase -i\".\n \t\t */\n \t\treturn error(_(\"%s: Unable to write new index file\"),\n-- \n2.11.0\n\n"},{"id":"319473","messageId":"20170511214125.GB21723@aiede.svl.corp.google.com","threadId":"45930","inReplyTo":"20170511212012.6782-1-avarab@gmail.com","subject":"Re: [PATCH] C style: use standard style for \"TRANSLATORS\" comments","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2017-05-11T21:41:26Z","receivedAt":"2017-05-11T21:41:33Z","isPatch":true,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"Hi,\n\nÆvar Arnfjörð Bjarmason wrote:\n\n> Change all the \"TRANSLATORS: [...]\" comments in the C code to use the\n> regular Git coding style, and amend the style guide so that the\n> example there uses that style.\n\nHooray!\n\n[...]\n> --- a/Documentation/CodingGuidelines\n> +++ b/Documentation/CodingGuidelines\n> @@ -256,12 +256,12 @@ For C programs:\n>  \n>     Note however that a comment that explains a translatable string to\n\nThe \"Note however\" isn't needed since it's not contradicting\nthe previous point any more.  This can be an entirely separate item:\n\n - A comment that explains a translatable string to translators\n   uses a convention of starting with a magic token \"TRANSLATORS: \"\n   [etc]\n\nIt might even make sense to remove the explanation of TRANSLATORS\ncomments from this file altogether, since they're intuitive to use.\nA more common place to want to learn about them is po/README, which\nalready explains them.\n\n[...]\n> --- a/bisect.c\n> +++ b/bisect.c\n> @@ -995,8 +995,10 @@ int bisect_next_all(const char *prefix, int no_checkout)\n>  \n>  \tsteps_msg = xstrfmt(Q_(\"(roughly %d step)\", \"(roughly %d steps)\",\n>  \t\t  steps), steps);\n> -\t/* TRANSLATORS: the last %s will be replaced with\n> -\t   \"(roughly %d steps)\" translation */\n> +\t/*\n> +\t * TRANSLATORS: the last %s will be replaced with \"(roughly %d\n> +\t * steps)\" translation.\n> +\t */\n\nNice.\n\n[...]\n> +++ b/ref-filter.c\n> @@ -1251,13 +1251,17 @@ char *get_head_description(void)\n>  \t\t\t    state.branch);\n>  \telse if (state.detached_from) {\n>  \t\tif (state.detached_at)\n> -\t\t\t/* TRANSLATORS: make sure this matches\n> -\t\t\t   \"HEAD detached at \" in wt-status.c */\n> +\t\t\t/*\n> +\t\t\t * TRANSLATORS: make sure this matches \"HEAD\n> +\t\t\t * detached at \" in wt-status.c\n> +\t\t\t */\n\noptional: could treat \"HEAD detached at \" as an unbreakable phrase\nfor the sake of line-breaking, for easier grepping.\n\nBut what's here is also perfectly fine.\n\n[...]\n> -\t\t\t/* TRANSLATORS: make sure this matches\n> -\t\t\t   \"HEAD detached from \" in wt-status.c */\n> +\t\t\t/*\n> +\t\t\t * TRANSLATORS: make sure this matches \"HEAD\n> +\t\t\t * detached from \" in wt-status.c\n> +\t\t\t */\n\nLikewise.\n\nThe rest also look good. This is great.\n\nThanks,\nJonathan\n"},{"id":"319474","messageId":"20170511215005.GN83655@google.com","threadId":"45930","inReplyTo":"20170511214125.GB21723@aiede.svl.corp.google.com","subject":"Re: [PATCH] C style: use standard style for \"TRANSLATORS\" comments","fromName":"Brandon Williams","fromEmail":"bmwill@google.com","sentAt":"2017-05-11T21:50:05Z","receivedAt":"2017-05-11T21:50:14Z","isPatch":true,"sender":{"key":"bwilliams.eng@gmail.com","avatar":null},"body":"On 05/11, Jonathan Nieder wrote:\n> Hi,\n> \n> Ævar Arnfjörð Bjarmason wrote:\n> \n> > Change all the \"TRANSLATORS: [...]\" comments in the C code to use the\n> > regular Git coding style, and amend the style guide so that the\n> > example there uses that style.\n> \n> Hooray!\n> \n> [...]\n> > --- a/Documentation/CodingGuidelines\n> > +++ b/Documentation/CodingGuidelines\n> > @@ -256,12 +256,12 @@ For C programs:\n> >  \n> >     Note however that a comment that explains a translatable string to\n> \n> The \"Note however\" isn't needed since it's not contradicting\n> the previous point any more.  This can be an entirely separate item:\n> \n>  - A comment that explains a translatable string to translators\n>    uses a convention of starting with a magic token \"TRANSLATORS: \"\n>    [etc]\n> \n> It might even make sense to remove the explanation of TRANSLATORS\n> comments from this file altogether, since they're intuitive to use.\n> A more common place to want to learn about them is po/README, which\n> already explains them.\n> \n> [...]\n> > --- a/bisect.c\n> > +++ b/bisect.c\n> > @@ -995,8 +995,10 @@ int bisect_next_all(const char *prefix, int no_checkout)\n> >  \n> >  \tsteps_msg = xstrfmt(Q_(\"(roughly %d step)\", \"(roughly %d steps)\",\n> >  \t\t  steps), steps);\n> > -\t/* TRANSLATORS: the last %s will be replaced with\n> > -\t   \"(roughly %d steps)\" translation */\n> > +\t/*\n> > +\t * TRANSLATORS: the last %s will be replaced with \"(roughly %d\n> > +\t * steps)\" translation.\n> > +\t */\n> \n> Nice.\n> \n> [...]\n> > +++ b/ref-filter.c\n> > @@ -1251,13 +1251,17 @@ char *get_head_description(void)\n> >  \t\t\t    state.branch);\n> >  \telse if (state.detached_from) {\n> >  \t\tif (state.detached_at)\n> > -\t\t\t/* TRANSLATORS: make sure this matches\n> > -\t\t\t   \"HEAD detached at \" in wt-status.c */\n> > +\t\t\t/*\n> > +\t\t\t * TRANSLATORS: make sure this matches \"HEAD\n> > +\t\t\t * detached at \" in wt-status.c\n> > +\t\t\t */\n> \n> optional: could treat \"HEAD detached at \" as an unbreakable phrase\n> for the sake of line-breaking, for easier grepping.\n> \n> But what's here is also perfectly fine.\n> \n> [...]\n> > -\t\t\t/* TRANSLATORS: make sure this matches\n> > -\t\t\t   \"HEAD detached from \" in wt-status.c */\n> > +\t\t\t/*\n> > +\t\t\t * TRANSLATORS: make sure this matches \"HEAD\n> > +\t\t\t * detached from \" in wt-status.c\n> > +\t\t\t */\n> \n> Likewise.\n> \n> The rest also look good. This is great.\n\nI agree with Jonathan.  I like having everything more uniform :)\n\n-- \nBrandon Williams\n"},{"id":"319501","messageId":"afa831d6-efb2-7e20-64a8-9ef338a28016@kdbg.org","threadId":"45930","inReplyTo":"20170511212012.6782-1-avarab@gmail.com","subject":"Re: [PATCH] C style: use standard style for \"TRANSLATORS\" comments","fromName":"Johannes Sixt","fromEmail":"j6t@kdbg.org","sentAt":"2017-05-12T05:20:08Z","receivedAt":"2017-05-12T18:44:31Z","isPatch":true,"sender":{"key":"j6t@kdbg.org","avatar":"https://avatars.githubusercontent.com/u/14810926?v=4"},"body":"Am 11.05.2017 um 23:20 schrieb Ævar Arnfjörð Bjarmason:\n> diff --git a/builtin/notes.c b/builtin/notes.c\n> index 7b891471c4..fb856e53b6 100644\n> --- a/builtin/notes.c\n> +++ b/builtin/notes.c\n> @@ -340,8 +340,10 @@ static struct notes_tree *init_notes_check(const char *subcommand,\n>   \n>   \tref = (flags & NOTES_INIT_WRITABLE) ? t->update_ref : t->ref;\n>   \tif (!starts_with(ref, \"refs/notes/\"))\n> -\t\t/* TRANSLATORS: the first %s will be replaced by a\n> -\t\t   git notes command: 'add', 'merge', 'remove', etc.*/\n> +\t\t/*\n> +\t\t * TRANSLATORS: the first %s will be replaced by a git\n> +\t\t * notes command: 'add', 'merge', 'remove', etc.\n> +\t\t */\n\nRewrapping lines is generally frowned upon because it makes it difficult \nto see whether something was changed. Keeping the line wrapping will \nalso reduce the noise in the next .pot commit, I think (not sure if that \nis a worthwhile goal, though).\n\n<rant>\nI hate it when J. Random Developer insists in a particular line length \nand when they have their editor do the wrapping, logical entities are \nsuddenly split into two lines: it is \"git notes\", one logical thing; not \ntwo words \"git\" \"notes\" that happen to occur in sequence.\n</rant>\n\n-- Hannes\n"},{"id":"319534","messageId":"xmqqwp9m7k9z.fsf@gitster.mtv.corp.google.com","threadId":"45930","inReplyTo":"20170511091829.5634-5-avarab@gmail.com","subject":"Re: [PATCH 04/29] log: add exhaustive tests for pattern style options & config","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2017-05-12T04:48:24Z","receivedAt":"2017-05-12T18:45:30Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Ævar Arnfjörð Bjarmason  <avarab@gmail.com> writes:\n\n> Add exhaustive tests for how the different grep.patternType options &\n> the corresponding command-line options affect git-log.\n> ...\n> The patterns being passed to fixed/basic/extended/PCRE are carefully\n> crafted to return the wrong thing if the grep engine were to pick any\n> other matching method than the one it's told to use.\n\nThat is good; it may be even more helpful to the readers if they are\ngiven a brief in-code comment.  I had to scratch head while reading\nthem.\n\n>\n> Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n> ---\n>  t/t4202-log.sh | 77 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++-\n>  1 file changed, 76 insertions(+), 1 deletion(-)\n>\n> diff --git a/t/t4202-log.sh b/t/t4202-log.sh\n> index f577990716..6d1411abea 100755\n> --- a/t/t4202-log.sh\n> +++ b/t/t4202-log.sh\n> @@ -262,7 +262,23 @@ 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# BRE 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> +\techo 2e >expect &&\n\t# In PCRE \\d in [\\d] is like saying \"0-9\", and match '2' in 2e\n> +\tgit -C num_commits log -1 --pretty=\"tformat:%s\" -F -E --perl-regexp --grep=\"[\\d]\" >actual &&\n> +\ttest_cmp expect actual &&\n> +\techo 1d >expect &&\n\t# In ERE [\\d] is bs or letter 'd' and would not match '2' in '2e'\n\t# but does match 'd' in '1d'\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 +296,65 @@ 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> +\t\ttest_commit \"(1|2)\" file B &&\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# Fixed finds these literally\n> +\t\tgit -c grep.patternType=fixed log --pretty=tformat:%s \\\n> +\t\t\t--grep=\"(1|2)\" >actual.fixed &&\n\t\t# BRE matches (, |, and ) literally\n> +\t\tgit -c grep.patternType=basic log --pretty=tformat:%s \\\n> +\t\t\t--grep=\"(.|.)\" >actual.basic &&\n\t\t# ERE needs | quoted with bs to match | literally\n> +\t\tgit -c grep.patternType=extended log --pretty=tformat:%s \\\n> +\t\t\t--grep=\"\\|2\" >actual.extended &&\n\nIf we use BRE by mistake, wouldn't this pattern actually find\n\"(1|2)\" anyway, without skipping it and show \"1 file A\" instead?\n\n> +\t\tif test_have_prereq PCRE\n> +\t\tthen\n> +\t\t\tgit -c grep.patternType=perl log --pretty=tformat:%s \\\n> +\t\t\t\t--grep=\"[\\d]\\|\" >actual.perl\n\t\t\t# Only PCRE would match [\\d]\\| with \"(1|2)\" due to [\\d]\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> +\t\tif test_have_prereq PCRE\n> +\t\tthen\n> +\t\t\ttest_cmp expect.perl actual.perl\n> +\t\tfi &&\n\nIt could be just a style thing, but I would actually find it easier\nto follow if the above two \"only with PCRE\" tests, i.e. running test\nand taking its output in actual.perl and comparing it with\nexpect.perl, were inside a single \"if test_have_prereq PCRE\" block.\n"},{"id":"319535","messageId":"xmqqpofe7jrq.fsf@gitster.mtv.corp.google.com","threadId":"45930","inReplyTo":"20170511091829.5634-10-avarab@gmail.com","subject":"Re: [PATCH 09/29] grep: amend submodule recursion test for regex engine testing","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2017-05-12T04:59:21Z","receivedAt":"2017-05-12T18:45:31Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Ævar Arnfjörð Bjarmason  <avarab@gmail.com> writes:\n\n> Amend the submodule recursion test to prepare it for subsequent tests\n> of whether it passes along the grep.patternType to the submodule\n> greps.\n>\n> This is the result of searching & replacing:\n>\n>     foobar -> (1|2)d(3|4)\n>     foo    -> (1|2)\n>     bar    -> (3|4)\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)d\" --recurse-submodules >actual &&\n\n\nThis breaks the promise \"foo maps to (1|2)\"; I do not think you need\nto add 'd' in order to make the test to succeed, so I am not sure\nwhat is going on here.\n\n"},{"id":"319539","messageId":"xmqqlgq27jgl.fsf@gitster.mtv.corp.google.com","threadId":"45930","inReplyTo":"20170511091829.5634-12-avarab@gmail.com","subject":"Re: [PATCH 11/29] grep: add a test helper function for less verbose -f \\0 tests","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2017-05-12T05:06:02Z","receivedAt":"2017-05-12T18:45:37Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Ævar Arnfjörð Bjarmason  <avarab@gmail.com> writes:\n\n> 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\n> subsequent commits will add a lot more of these tests.\n>\n> The helper is based on the match() function in t3070-wildmatch.sh.\n>\n> Signed-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>\n> diff --git a/t/t7008-grep-binary.sh b/t/t7008-grep-binary.sh\n> index 9c9c378119..6c1952eafa 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\nMicronit: \"nul_match () {\"\n\n> +\tstatus=$1\n> +\tflags=$2\n> +\tpattern=$3\n> +\tpattern_human=$(echo $pattern | sed 's/Q/<NUL>/g')\n\nDouble quote around \"$pattern\"?\n\n> +\n> +\tif test $status = \"1\"\n\nDouble quote around \"$status\" and drop double quote around \"1\"\n(which is clearly a literal string without any funnies) instead?\n\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 $status = \"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\nIt somehow was unintuitive that 0 expected failure and 1 expected\nsuccess, but it probably was just me.\n"},{"id":"319613","messageId":"CACBZZX4MK8=YixozpbPjJh1JxHcFr9x6GoXJeA34E-qLn6ZSDw@mail.gmail.com","threadId":"45930","inReplyTo":"xmqqlgq27jgl.fsf@gitster.mtv.corp.google.com","subject":"Re: [PATCH 11/29] grep: add a test helper function for less verbose -f \\0 tests","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2017-05-13T11:33:49Z","receivedAt":"2017-05-13T11:34:17Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"On Fri, May 12, 2017 at 7:06 AM, Junio C Hamano <gitster@pobox.com> wrote:\n> Ævar Arnfjörð Bjarmason  <avarab@gmail.com> writes:\n>\n>> 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\n>> subsequent commits will add a lot more of these tests.\n>>\n>> The helper is based on the match() function in t3070-wildmatch.sh.\n>>\n>> Signed-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>>\n>> diff --git a/t/t7008-grep-binary.sh b/t/t7008-grep-binary.sh\n>> index 9c9c378119..6c1952eafa 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>\n> Micronit: \"nul_match () {\"\n>\n>> +     status=$1\n>> +     flags=$2\n>> +     pattern=$3\n>> +     pattern_human=$(echo $pattern | sed 's/Q/<NUL>/g')\n>\n> Double quote around \"$pattern\"?\n>\n>> +\n>> +     if test $status = \"1\"\n>\n> Double quote around \"$status\" and drop double quote around \"1\"\n> (which is clearly a literal string without any funnies) instead?\n>\n>> +     then\n>> +             test_expect_success \"git grep -f f $flags '$pattern_human' a\" \"\n>> +                     printf '$pattern' | q_to_nul >f &&\n>> +                     git grep -f f $flags a\n>> +             \"\n>> +     elif test $status = \"0\"\n>> +     then\n>> +             test_expect_success \"git grep -f f $flags '$pattern_human' a\" \"\n>> +                     printf '$pattern' | q_to_nul >f &&\n>> +                     test_must_fail git grep -f f $flags a\n>> +             \"\n\nAll changed in v2.\n\n> It somehow was unintuitive that 0 expected failure and 1 expected\n> success, but it probably was just me.\n\nExcept this. The wildmatch uses the same idiom, and I think it makes\nsense. 1 = true, 0 = false, not 0 = exit zero, 1 = exit nonzero, which\nwould also be IMO a bit more confusing since it should really be 0 and\n!0 if you don't want to rely on specific non-zero exit codes, which is\njust going down a garden path of complexity when all we wanted was\n\"does this match\".\n"},{"id":"319625","messageId":"CACBZZX6P=q=nAx4LinGG1877HitkrzC_dRL+9b4u7D38r3u_8g@mail.gmail.com","threadId":"45930","inReplyTo":"xmqqpofe7jrq.fsf@gitster.mtv.corp.google.com","subject":"Re: [PATCH 09/29] grep: amend submodule recursion test for regex engine testing","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2017-05-13T17:33:08Z","receivedAt":"2017-05-13T17:33:36Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"On Fri, May 12, 2017 at 6:59 AM, Junio C Hamano <gitster@pobox.com> wrote:\n> Ævar Arnfjörð Bjarmason  <avarab@gmail.com> writes:\n>\n>> Amend the submodule recursion test to prepare it for subsequent tests\n>> of whether it passes along the grep.patternType to the submodule\n>> greps.\n>>\n>> This is the result of searching & replacing:\n>>\n>>     foobar -> (1|2)d(3|4)\n>>     foo    -> (1|2)\n>>     bar    -> (3|4)\n>> ...\n>>  test_expect_success 'grep and multiple patterns' '\n>>       cat >expect <<-\\EOF &&\n>> -     b/b:bar\n>> +     b/b:(3|4)\n>>       EOF\n>>\n>> -     git grep -e \"bar\" --and --not -e \"foo\" --recurse-submodules >actual &&\n>> +     git grep -e \"(3|4)\" --and --not -e \"(1|2)d\" --recurse-submodules >actual &&\n>\n>\n> This breaks the promise \"foo maps to (1|2)\"; I do not think you need\n> to add 'd' in order to make the test to succeed, so I am not sure\n> what is going on here.\n\nThanks, fixing it. That was just a stupid mistake on my part, don't\nknow how that snuck in there, must have just fat-fingered (1|2) as\n(1|2)d during interactive replace.\n"},{"id":"319627","messageId":"CACBZZX5JDg7Ntpjc-J-jtei7jJthd0+gkSEONsWCx3Mfqeu8mA@mail.gmail.com","threadId":"45930","inReplyTo":"xmqqwp9m7k9z.fsf@gitster.mtv.corp.google.com","subject":"Re: [PATCH 04/29] log: add exhaustive tests for pattern style options & config","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2017-05-13T18:02:49Z","receivedAt":"2017-05-13T18:03:16Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"On Fri, May 12, 2017 at 6:48 AM, Junio C Hamano <gitster@pobox.com> wrote:\n> Ævar Arnfjörð Bjarmason  <avarab@gmail.com> writes:\n>\n>> Add exhaustive tests for how the different grep.patternType options &\n>> the corresponding command-line options affect git-log.\n>> ...\n>> The patterns being passed to fixed/basic/extended/PCRE are carefully\n>> crafted to return the wrong thing if the grep engine were to pick any\n>> other matching method than the one it's told to use.\n>\n> That is good; it may be even more helpful to the readers if they are\n> given a brief in-code comment.  I had to scratch head while reading\n> them.\n>\n>>\n>> Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n>> ---\n>>  t/t4202-log.sh | 77 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++-\n>>  1 file changed, 76 insertions(+), 1 deletion(-)\n>>\n>> diff --git a/t/t4202-log.sh b/t/t4202-log.sh\n>> index f577990716..6d1411abea 100755\n>> --- a/t/t4202-log.sh\n>> +++ b/t/t4202-log.sh\n>> @@ -262,7 +262,23 @@ test_expect_success 'log --grep -i' '\n>>\n>>  test_expect_success 'log -F -E --grep=<ere> uses ere' '\n>>       echo second >expect &&\n>> -     git log -1 --pretty=\"tformat:%s\" -F -E --grep=s.c.nd >actual &&\n>         # BRE would need \\(s\\) to do the same.\n>> +     git log -1 --pretty=\"tformat:%s\" -F -E --grep=\"(s).c.nd\" >actual &&\n>> +     test_cmp expect actual\n>> +'\n>> +\n>> +test_expect_success PCRE 'log -F -E --perl-regexp --grep=<pcre> uses PCRE' '\n>> +     test_when_finished \"rm -rf num_commits\" &&\n>> +     git init num_commits &&\n>> +     (\n>> +             cd num_commits &&\n>> +             test_commit 1d &&\n>> +             test_commit 2e\n>> +     ) &&\n>> +     echo 2e >expect &&\n>         # In PCRE \\d in [\\d] is like saying \"0-9\", and match '2' in 2e\n>> +     git -C num_commits log -1 --pretty=\"tformat:%s\" -F -E --perl-regexp --grep=\"[\\d]\" >actual &&\n>> +     test_cmp expect actual &&\n>> +     echo 1d >expect &&\n>         # In ERE [\\d] is bs or letter 'd' and would not match '2' in '2e'\n>         # but does match 'd' in '1d'\n>> +     git -C num_commits log -1 --pretty=\"tformat:%s\" -F -E --grep=\"[\\d]\" >actual &&\n>>       test_cmp expect actual\n>>  '\n>>\n>> @@ -280,6 +296,65 @@ test_expect_success 'log with grep.patternType configuration and command line' '\n>>       test_cmp expect actual\n>>  '\n>>\n>> +test_expect_success 'log with various grep.patternType configurations & command-lines' '\n>> +     git init pattern-type &&\n>> +     (\n>> +             cd pattern-type &&\n>> +             test_commit 1 file A &&\n>> +             test_commit \"(1|2)\" file B &&\n>> +\n>> +             echo \"(1|2)\" >expect.fixed &&\n>> +             cp expect.fixed expect.basic &&\n>> +             cp expect.fixed expect.extended &&\n>> +             cp expect.fixed expect.perl &&\n>> +\n>                 # Fixed finds these literally\n>> +             git -c grep.patternType=fixed log --pretty=tformat:%s \\\n>> +                     --grep=\"(1|2)\" >actual.fixed &&\n>                 # BRE matches (, |, and ) literally\n>> +             git -c grep.patternType=basic log --pretty=tformat:%s \\\n>> +                     --grep=\"(.|.)\" >actual.basic &&\n>                 # ERE needs | quoted with bs to match | literally\n>> +             git -c grep.patternType=extended log --pretty=tformat:%s \\\n>> +                     --grep=\"\\|2\" >actual.extended &&\n>\n> If we use BRE by mistake, wouldn't this pattern actually find\n> \"(1|2)\" anyway, without skipping it and show \"1 file A\" instead?\n\nIt'll find (1|2) but also 1, i.e.:\n\n$ (echo 1; echo \"(1|2)\") >/tmp/f; for t in G E; do echo $t: && grep\n-$t '\\|2' /tmp/f | sed 's/^/  /'; done\nG:\n  1\n  (1|2)\nE:\n  (1|2)\n\nSo the test will fail under basic. I'll add comments about this & the\nother things you suggested.\n\n>> +             if test_have_prereq PCRE\n>> +             then\n>> +                     git -c grep.patternType=perl log --pretty=tformat:%s \\\n>> +                             --grep=\"[\\d]\\|\" >actual.perl\n>                         # Only PCRE would match [\\d]\\| with \"(1|2)\" due to [\\d]\n>> +             fi &&\n>> +             test_cmp expect.fixed actual.fixed &&\n>> +             test_cmp expect.basic actual.basic &&\n>> +             test_cmp expect.extended actual.extended &&\n>> +             if test_have_prereq PCRE\n>> +             then\n>> +                     test_cmp expect.perl actual.perl\n>> +             fi &&\n>\n> It could be just a style thing, but I would actually find it easier\n> to follow if the above two \"only with PCRE\" tests, i.e. running test\n> and taking its output in actual.perl and comparing it with\n> expect.perl, were inside a single \"if test_have_prereq PCRE\" block.\n\nSure, will fix.\n"},{"id":"319736","messageId":"xmqqshk6ykkj.fsf@gitster.mtv.corp.google.com","threadId":"45930","inReplyTo":"CACBZZX4MK8=YixozpbPjJh1JxHcFr9x6GoXJeA34E-qLn6ZSDw@mail.gmail.com","subject":"Re: [PATCH 11/29] grep: add a test helper function for less verbose -f \\0 tests","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2017-05-15T01:29:00Z","receivedAt":"2017-05-15T01:29:07Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Ævar Arnfjörð Bjarmason <avarab@gmail.com> writes:\n\n>> It somehow was unintuitive that 0 expected failure and 1 expected\n>> success, but it probably was just me.\n>\n> Except this. The wildmatch uses the same idiom, and I think it makes\n> sense. 1 = true, 0 = false, ... when all we wanted was\n> \"does this match\".\n\nOK.  Makes perfect sense (it would have been even easier to\nunderstand if the variable was not $status but $matches or\nsomething).\n\n\n"},{"id":"321032","messageId":"CANYiYbH=EJy51yAdiMg6R_yDzZ3PLUuLMsLxdkf9zXJPhLcwKA@mail.gmail.com","threadId":"45930","inReplyTo":"20170511212012.6782-1-avarab@gmail.com","subject":"Re: [PATCH] C style: use standard style for \"TRANSLATORS\" comments","fromName":"Jiang Xin","fromEmail":"worldhello.net@gmail.com","sentAt":"2017-05-30T16:02:18Z","receivedAt":"2017-05-30T16:02:24Z","isPatch":true,"sender":{"key":"worldhello.net@gmail.com","avatar":"https://avatars.githubusercontent.com/u/183860?v=4"},"body":"2017-05-12 5:20 GMT+08:00 Ævar Arnfjörð Bjarmason <avarab@gmail.com>:\n> Change all the \"TRANSLATORS: [...]\" comments in the C code to use the\n> regular Git coding style, and amend the style guide so that the\n> example there uses that style.\n>\n> This custom style was necessary back in 2010 when the gettext support\n> was initially added, and was subsequently documented in commit\n> cbcfd4e3ea (\"i18n: mention \"TRANSLATORS:\" marker in\n> Documentation/CodingGuidelines\", 2014-04-18).\n>\n> GNU xgettext hasn't had the parsing limitation that necessitated this\n> exception for almost 3 years. Since its 0.19 release on 2014-06-02\n> it's been able to recognize TRANSLATOR comments in the standard Git\n> comment syntax[1].\n\nMy gettext version is 0.19.8.1.  I applied this patch and checked the\nnew generated `git.pot` file, all \"TRANSLATORS:\" directions are well\nkept as usual.\n\nThis patch is nice.\n\n-- \nJiang Xin\n"},{"id":"321089","messageId":"xmqqwp8y9ccl.fsf@gitster.mtv.corp.google.com","threadId":"45930","inReplyTo":"CANYiYbH=EJy51yAdiMg6R_yDzZ3PLUuLMsLxdkf9zXJPhLcwKA@mail.gmail.com","subject":"Re: [PATCH] C style: use standard style for \"TRANSLATORS\" comments","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2017-05-30T23:03:22Z","receivedAt":"2017-05-30T23:03:28Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Jiang Xin <worldhello.net@gmail.com> writes:\n\n> 2017-05-12 5:20 GMT+08:00 Ævar Arnfjörð Bjarmason <avarab@gmail.com>:\n>> Change all the \"TRANSLATORS: [...]\" comments in the C code to use the\n>> regular Git coding style, and amend the style guide so that the\n>> example there uses that style.\n>>\n>> This custom style was necessary back in 2010 when the gettext support\n>> was initially added, and was subsequently documented in commit\n>> cbcfd4e3ea (\"i18n: mention \"TRANSLATORS:\" marker in\n>> Documentation/CodingGuidelines\", 2014-04-18).\n>>\n>> GNU xgettext hasn't had the parsing limitation that necessitated this\n>> exception for almost 3 years. Since its 0.19 release on 2014-06-02\n>> it's been able to recognize TRANSLATOR comments in the standard Git\n>> comment syntax[1].\n>\n> My gettext version is 0.19.8.1.  I applied this patch and checked the\n> new generated `git.pot` file, all \"TRANSLATORS:\" directions are well\n> kept as usual.\n\nÆvar, sorry that this patch fell through cracks about 20 days ago.\nI'll queue with Acked-by by Jiang.\n\nThanks, both.\n"}]}