summaryrefslogtreecommitdiff
path: root/t/t7008-grep-binary.sh
diff options
context:
space:
mode:
authorÆvar Arnfjörð Bjarmason <avarab@gmail.com>2017-05-20 21:42:16 (GMT)
committerJunio C Hamano <gitster@pobox.com>2017-05-20 23:25:37 (GMT)
commit12fc32faa8b51d33f3793c45ea20ab02b9717574 (patch)
tree02dd3daa60df73930b45deb86bd403d82dd7161d /t/t7008-grep-binary.sh
parent77f6f4406fef43130e9c72e32ac5e30c5bbe0b9e (diff)
downloadgit-12fc32faa8b51d33f3793c45ea20ab02b9717574.zip
git-12fc32faa8b51d33f3793c45ea20ab02b9717574.tar.gz
git-12fc32faa8b51d33f3793c45ea20ab02b9717574.tar.bz2
grep: prepare for testing binary regexes containing rx metacharacters
Add setup code needed for testing regexes that contain both binary data and regex metacharacters. The POSIX regcomp() function inherently can't support that, because it takes a \0-delimited char *, but other regex engines APIs like PCRE v2 take a pattern/length pair, and are thus able to handle \0s in patterns as well as any other character. When kwset was imported in commit 9eceddeec6 ("Use kwset in grep", 2011-08-21) this limitation was fixed, but at the expense of introducing the undocumented limitation that any pattern containing \0 implicitly becomes a fixed match (equivalent to -F having been provided). That's not something we'd like to keep in the future. The inability to match patterns containing \0 is a leaky implementation detail. So add tests as a first step towards changing that. In order to test that \0-patterns can properly match as regexes the test string needs to have some regex metacharacters in it. There were other blind spots in the tests. The code around kwset specially handles case-insensitive & non-ASCII data, but there were no tests for this. Fix all of that by amending the text being matched to contain both regex metacharacters & non-ASCII data. Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't/t7008-grep-binary.sh')
-rwxr-xr-xt/t7008-grep-binary.sh6
1 files changed, 3 insertions, 3 deletions
diff --git a/t/t7008-grep-binary.sh b/t/t7008-grep-binary.sh
index df93d8e..20370d6 100755
--- a/t/t7008-grep-binary.sh
+++ b/t/t7008-grep-binary.sh
@@ -28,7 +28,7 @@ nul_match () {
}
test_expect_success 'setup' "
- echo 'binaryQfile' | q_to_nul >a &&
+ echo 'binaryQfileQm[*]cQ*æQð' | q_to_nul >a &&
git add a &&
git commit -m.
"
@@ -162,7 +162,7 @@ test_expect_success 'grep does not honor textconv' '
'
test_expect_success 'grep --textconv honors textconv' '
- echo "a:binaryQfile" >expect &&
+ echo "a:binaryQfileQm[*]cQ*æQð" >expect &&
git grep --textconv Qfile >actual &&
test_cmp expect actual
'
@@ -172,7 +172,7 @@ test_expect_success 'grep --no-textconv does not honor textconv' '
'
test_expect_success 'grep --textconv blob honors textconv' '
- echo "HEAD:a:binaryQfile" >expect &&
+ echo "HEAD:a:binaryQfileQm[*]cQ*æQð" >expect &&
git grep --textconv Qfile HEAD:a >actual &&
test_cmp expect actual
'