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

Re: [PATCH v2 04/29] log: add exhaustive tests for pattern style options & config

From
Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Date
May 15, 2017, 17:38 UTC
Message-ID
<CACBZZX4EfWCD3rwQbRJ1TokDkH=7EfoepMd_ipHr5NSv9kWOJg@mail.gmail.com>
In-Reply-To
<xmqq1srqwwbu.fsf@gitster.mtv.corp.google.com>
On Mon, May 15, 2017 at 6:57 AM, Junio C Hamano <gitster@pobox.com> wrote:
Show 12 quoted lines
> Ævar Arnfjörð Bjarmason  <avarab@gmail.com> writes:
>
>> +     echo 2e >expect &&
>> +     # In PCRE \d in [\d] is like saying "0-9", and matches the 2
>> +     # in 2e...
>> +     git -C num_commits log -1 --pretty="tformat:%s" -F -E --perl-regexp --grep="[\d]" >actual &&
>> +     test_cmp expect actual &&
>> +     echo 1d >expect &&
>> +     # ...in POSIX basic & extended it is the same as [d],
>> +     # i.e. "d", which matches 1d, but not and does not match 2e.
>
> s/not and//; I think.
Will fix.
Show 39 quoted lines
>> +     git -C num_commits log -1 --pretty="tformat:%s" -F -E --grep="[\d]" >actual &&
>>       test_cmp expect actual
>>  '
>>
>> @@ -280,6 +301,77 @@ test_expect_success 'log with grep.patternType configuration and command line' '
>>       test_cmp expect actual
>>  '
>>
>> +test_expect_success 'log with various grep.patternType configurations & command-lines' '
>> +     git init pattern-type &&
>> +     (
>> +             cd pattern-type &&
>> +             test_commit 1 file A &&
>> +
>> +             # The tagname is overridden here because creating a
>> +             # tag called "(1|2)" as test_commit would otherwise
>> +             # implicitly do would fail on e.g. MINGW.
>
> Thanks.
>
>> +             # POSIX extended needs to have | escaped to match it
>> +             # literally, whereas under basic this is the same as
>> +             # (|2), i.e. it would also match "1". This test checks
>> +             # for extended by asserting that it is not matching
>> +             # what basic would match.
>> +             git -c grep.patternType=extended log --pretty=tformat:%s \
>> +                     --grep="\|2" >actual.extended &&
>
> Makes sense.
>
>> +             if test_have_prereq PCRE
>> +             then
>> +                     # Only PCRE would match [\d]\| with only
>> +                     # "(1|2)" due to [\d]. POSIX basic would match
>> +                     # both it and "1", and POSIX extended would
>> +                     # match neither.
>
> OK.  BRE would match because the other side of "\|" is empty to
> match anything?

Yes. I'll clarify this. It's not just a POSIX basic feature. The same is true of extended and perl. E.g.:

    git grep [-E|-P] 'foo|bar'
Both match the same as:
    git grep [-E|-P] '(foo|bar)'
Show 5 quoted lines
>> +                     git -c grep.patternType=perl log --pretty=tformat:%s \
>> +                             --grep="[\d]\|" >actual.perl &&
>> +                     test_cmp expect.perl actual.perl
>> +             fi &&
>
Previous: Junio C HamanoNext: Junio C Hamano
Message 6 of 42 in “Easy to review grep & pre-PCRE changes”
  1. 00/29 Easy to review grep & pre-PCRE changesÆvar Arnfjörð Bjarmason, May 13, 2017
  2. 01/29 Makefile & configure: reword inaccurate comment about PCREÆvar Arnfjörð Bjarmason, May 13, 2017
  3. 02/29 grep & rev-list doc: stop promising libpcre for --perl-regexpÆvar Arnfjörð Bjarmason, May 13, 2017
  4. 04/29 log: add exhaustive tests for pattern style options & configÆvar Arnfjörð Bjarmason, May 13, 2017
  5. Junio C HamanoMay 15, 2017
  6. Ævar Arnfjörð BjarmasonMay 15, 2017
  7. Junio C HamanoMay 16, 2017
  8. 05/29 grep: add a test asserting that --perl-regexp dies when !PCREÆvar Arnfjörð Bjarmason, May 13, 2017
  9. 03/29 test-lib: rename the LIBPCRE prerequisite to PCREÆvar Arnfjörð Bjarmason, May 13, 2017
  10. 06/29 grep: add a test for backreferences in PCRE patternsÆvar Arnfjörð Bjarmason, May 13, 2017
  11. 07/29 grep: change non-ASCII -i test to stop using --debugÆvar Arnfjörð Bjarmason, May 13, 2017
  12. 08/29 grep: add tests for --threads=N and grep.threadsÆvar Arnfjörð Bjarmason, May 13, 2017
  13. 09/29 grep: amend submodule recursion test for regex engine testingÆvar Arnfjörð Bjarmason, May 13, 2017
  14. 10/29 grep: add tests for grep pattern types being passed to submodulesÆvar Arnfjörð Bjarmason, May 13, 2017
  15. 11/29 grep: add a test helper function for less verbose -f \0 testsÆvar Arnfjörð Bjarmason, May 13, 2017
  16. 12/29 grep: prepare for testing binary regexes containing rx metacharactersÆvar Arnfjörð Bjarmason, May 13, 2017
  17. 13/29 grep: add tests to fix blind spots with \0 patternsÆvar Arnfjörð Bjarmason, May 13, 2017
  18. 14/29 perf: add a GIT_PERF_MAKE_COMMAND for when *_MAKE_OPTS won't doÆvar Arnfjörð Bjarmason, May 13, 2017
  19. 15/29 perf: emit progress output when unpacking & buildingÆvar Arnfjörð Bjarmason, May 13, 2017
  20. 16/29 perf: add a performance comparison test of grep -G, -E and -PÆvar Arnfjörð Bjarmason, May 13, 2017
  21. 18/29 grep: catch a missing enum in switch statementÆvar Arnfjörð Bjarmason, May 13, 2017
  22. Junio C HamanoMay 15, 2017
  23. Ævar Arnfjörð BjarmasonMay 15, 2017
  24. 17/29 perf: add a performance comparison of fixed-string grepÆvar Arnfjörð Bjarmason, May 13, 2017
  25. 20/29 grep: remove redundant `regflags &= ~REG_EXTENDED` assignmentsÆvar Arnfjörð Bjarmason, May 13, 2017
  26. Junio C HamanoMay 15, 2017
  27. Ævar Arnfjörð BjarmasonMay 15, 2017
  28. 19/29 grep: remove redundant regflags assignment under PCREÆvar Arnfjörð Bjarmason, May 13, 2017
  29. 21/29 grep: factor test for \0 in grep patterns into a functionÆvar Arnfjörð Bjarmason, May 13, 2017
  30. Junio C HamanoMay 15, 2017
  31. Ævar Arnfjörð BjarmasonMay 15, 2017
  32. 22/29 grep: change the internal PCRE macro names to be PCRE1Ævar Arnfjörð Bjarmason, May 13, 2017
  33. 23/29 grep: change internal *pcre* variable & function names to be *pcre1*Ævar Arnfjörð Bjarmason, May 13, 2017
  34. 25/29 test-lib: add a PTHREADS prerequisiteÆvar Arnfjörð Bjarmason, May 13, 2017
  35. 26/29 pack-objects & index-pack: add test for --threads warningÆvar Arnfjörð Bjarmason, May 13, 2017
  36. 24/29 grep: move is_fixed() earlier to avoid forward declarationÆvar Arnfjörð Bjarmason, May 13, 2017
  37. 27/29 pack-objects: fix buggy warning about threadsÆvar Arnfjörð Bjarmason, May 13, 2017
  38. Junio C HamanoMay 15, 2017
  39. Ævar Arnfjörð BjarmasonMay 15, 2017
  40. 28/29 grep: given --threads with NO_PTHREADS=YesPlease, warnÆvar Arnfjörð Bjarmason, May 13, 2017
  41. 29/29 grep: assert that threading is enabled when calling grep_{lock,unlock}Ævar Arnfjörð Bjarmason, May 13, 2017
  42. Junio C HamanoMay 15, 2017

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

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