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>
This commit is contained in:
René Scharfe
2010-05-22 23:43:43 +02:00
committed by Junio C Hamano
parent f96e56733a
commit ed40a0951c
4 changed files with 58 additions and 15 deletions

View File

@ -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