Re: [PATCH v2 04/29] log: add exhaustive tests for pattern style options & config
- Date: Tue, 16 May 2017 09:50:43 +0900
- From: Junio C Hamano <gitster@xxxxxxxxx>
- Subject: Re: [PATCH v2 04/29] log: add exhaustive tests for pattern style options & config
Ævar Arnfjörð Bjarmason <avarab@xxxxxxxxx> writes:
> On Mon, May 15, 2017 at 6:57 AM, Junio C Hamano <gitster@xxxxxxxxx> wrote:
>> Ævar Arnfjörð Bjarmason <avarab@xxxxxxxxx> writes:
>>> + 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.:
Yes, but "\|" won't be taken as alternative in ERE or PCRE, and that
is why "[\d]\|" would match everything with BRE (as opposed to
others---PCRE matches "(1|2)" not because "\|" is an alternative but
because the pattern looks for a digit followed by a literal vert-bar,
and ERE does not match any because there is no 'd' followed by a
I was mostly reacting to "BRE would match both it and '1'", which
singled out "1" as if "1" is special and gives a false impression
that it wouldn't have matched if it were "7".
> git grep [-E|-P] 'foo|bar'
> Both match the same as:
> git grep [-E|-P] '(foo|bar)'
>>> + git -c grep.patternType=perl log --pretty=tformat:%s \
>>> + --grep="[\d]\|" >actual.perl &&
>>> + test_cmp expect.perl actual.perl
>>> + fi &&