diff options
author | René Scharfe <rene.scharfe@lsrfire.ath.cx> | 2010-05-23 01:43:43 +0400 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2010-05-24 22:22:07 +0400 |
commit | ed40a0951cedb70777669144478166aa5bb2cf9c (patch) | |
tree | 5683f6f847d31d83e2ddf9ff38f953eff916aa10 /t/t7008-grep-binary.sh | |
parent | f96e56733ab3e3ce5c79c27c673c746af1519a86 (diff) |
grep: support NUL chars in search strings for -F
Search patterns in a file specified with -f can contain NUL characters.
The current code ignores all characters on a line after a NUL.
Pass the actual length of the line all the way from the pattern file to
fixmatch() and use it for case-sensitive fixed string matching.
Signed-off-by: Rene Scharfe <rene.scharfe@lsrfire.ath.cx>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't/t7008-grep-binary.sh')
-rwxr-xr-x | t/t7008-grep-binary.sh | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/t/t7008-grep-binary.sh b/t/t7008-grep-binary.sh index 4f5e74fed7..eb8ca88cce 100755 --- a/t/t7008-grep-binary.sh +++ b/t/t7008-grep-binary.sh @@ -69,4 +69,34 @@ test_expect_failure 'git grep .fi a' ' git grep .fi a ' +test_expect_success 'git grep -F y<NUL>f a' " + printf 'y\000f' >f && + git grep -f f -F a +" + +test_expect_success 'git grep -F y<NUL>x a' " + printf 'y\000x' >f && + test_must_fail git grep -f f -F a +" + +test_expect_success 'git grep -Fi Y<NUL>f a' " + printf 'Y\000f' >f && + git grep -f f -Fi a +" + +test_expect_failure 'git grep -Fi Y<NUL>x a' " + printf 'Y\000x' >f && + test_must_fail git grep -f f -Fi a +" + +test_expect_success 'git grep y<NUL>f a' " + printf 'y\000f' >f && + git grep -f f a +" + +test_expect_failure 'git grep y<NUL>x a' " + printf 'y\000x' >f && + test_must_fail git grep -f f a +" + test_done |