diff options
author | Ævar Arnfjörð Bjarmason <avarab@gmail.com> | 2017-05-20 21:42:10 +0000 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2017-05-21 08:25:37 +0900 |
commit | 4aeb720d3f997bf09cff2c8c92f74da400950b24 (patch) | |
tree | 1067f5d08a7b86c02516b5017c89fcd6327b8d12 | |
parent | 9001c1920c9b812efc671bdc0c313d0a3418d8ee (diff) | |
download | git-4aeb720d3f997bf09cff2c8c92f74da400950b24.tar.gz |
grep: add a test for backreferences in PCRE patterns
Add a test for backreferences such as (.)\1 in PCRE patterns. This
test ensures that the PCRE_NO_AUTO_CAPTURE option isn't turned
on. Before this change turning it on would break these sort of
patterns, but wouldn't break any tests.
Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
-rwxr-xr-x | t/t7810-grep.sh | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/t/t7810-grep.sh b/t/t7810-grep.sh index 8d69113695..daa906b9b0 100755 --- a/t/t7810-grep.sh +++ b/t/t7810-grep.sh @@ -1114,6 +1114,13 @@ test_expect_success PCRE 'grep -P -w pattern' ' test_cmp expected actual ' +test_expect_success PCRE 'grep -P backreferences work (the PCRE NO_AUTO_CAPTURE flag is not set)' ' + git grep -P -h "(?P<one>.)(?P=one)" hello_world >actual && + test_cmp hello_world actual && + git grep -P -h "(.)\1" hello_world >actual && + test_cmp hello_world actual +' + test_expect_success 'grep -G invalidpattern properly dies ' ' test_must_fail git grep -G "a[" ' |