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>

Ævar Arnfjörð Bjarmason committed May 20, 2017 at 21:42 UTC 4aeb720d3f997bf09cff2c8c92f74da400950b24
1 file changed +7
t/t7810-grep.sh
+7
@@ -1114,6 +1114,13 @@ test_expect_success PCRE 'grep -P -w pattern' '
1114 test_cmp expected actual
1115 '
1116
1117 +test_expect_success PCRE 'grep -P backreferences work (the PCRE NO_AUTO_CAPTURE flag is not set)' '
1118 + git grep -P -h "(?P<one>.)(?P=one)" hello_world >actual &&
1119 + test_cmp hello_world actual &&
1120 + git grep -P -h "(.)\1" hello_world >actual &&
1121 + test_cmp hello_world actual
1122 +'
1123 +
1124 test_expect_success 'grep -G invalidpattern properly dies ' '
1125 test_must_fail git grep -G "a["
1126 '