Re: [PATCH v2 04/29] log: add exhaustive tests for pattern style options & config
- From
Junio C Hamano <gitster@pobox.com>
- Date
- May 16, 2017, 00:50 UTC
- Message-ID
- <xmqqy3tx4obg.fsf@gitster.mtv.corp.google.com>
- In-Reply-To
- <CACBZZX4EfWCD3rwQbRJ1TokDkH=7EfoepMd_ipHr5NSv9kWOJg@mail.gmail.com>
Ævar Arnfjörð Bjarmason <avarab@gmail.com> writes:
Show 14 quoted lines
> On Mon, May 15, 2017 at 6:57 AM, Junio C Hamano <gitster@pobox.com> wrote: >> Ævar Arnfjörð Bjarmason <avarab@gmail.com> 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 literal vert-bar).
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".
Show 12 quoted lines
> > 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 && >>