t7810: avoid assumption about invalid regex syntax
authorJeff King <peff@peff.net>
Wed, 11 Jan 2017 11:10:55 +0000 (06:10 -0500)
committerJunio C Hamano <gitster@pobox.com>
Wed, 11 Jan 2017 20:51:28 +0000 (12:51 -0800)
commit7675c7bd01b8d39dc3c1e8385403f0307be31712
treee0f62ac0c3721509046866f6d7d5391e40f8ed32
parent0b65a8dbdb38962e700ee16776a3042beb489060
t7810: avoid assumption about invalid regex syntax

A few of the tests want to check that "git grep -P -E" will
override -P with -E, and vice versa. To do so, we use a
regex with "\x{..}", which is valid in PCRE but not defined
by POSIX (for basic or extended regular expressions).

However, POSIX declares quite a lot of syntax, including
"\x", as "undefined". That leaves implementations free to
extend the standard if they choose. At least one, musl libc,
implements "\x" in the same way as PCRE.  Our tests check
that "-E" complains about "\x", which fails with musl.

We can fix this by finding some construct which behaves
reliably on both PCRE and POSIX, but differently in each
system.

One such construct is the use of backslash inside brackets.
In PCRE, "[\d]" interprets "\d" as it would outside the
brackets, matching a digit. Whereas in POSIX, the backslash
must be treated literally, and we match either it or a
literal "d".  Moreover, implementations are not free to
change this according to POSIX, so we should be able to rely
on it.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
t/t7810-grep.sh