summaryrefslogtreecommitdiff
path: root/t/t7008-grep-binary.sh
diff options
context:
space:
mode:
authorLibravatar Michael J Gruber <git@drmicha.warpmail.net>2013-05-10 17:10:14 +0200
committerLibravatar Junio C Hamano <gitster@pobox.com>2013-05-10 10:27:28 -0700
commit97f6a9c975bb14688b60a5134069159b4cae1a07 (patch)
treea6491ba0f438af29e3245d50f2d72308670562a0 /t/t7008-grep-binary.sh
parentcat-file: do not die on --textconv without textconv filters (diff)
downloadtgif-97f6a9c975bb14688b60a5134069159b4cae1a07.tar.xz
t7008: demonstrate behavior of grep with textconv
Currently, "git grep" does not honor any textconv filters, with nor without --textconv. Demonstrate this in the tests. The default is expected to remain unchanged. Signed-off-by: Michael J Gruber <git@drmicha.warpmail.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't/t7008-grep-binary.sh')
-rwxr-xr-xt/t7008-grep-binary.sh31
1 files changed, 31 insertions, 0 deletions
diff --git a/t/t7008-grep-binary.sh b/t/t7008-grep-binary.sh
index 26f831984d..1c0946f844 100755
--- a/t/t7008-grep-binary.sh
+++ b/t/t7008-grep-binary.sh
@@ -145,4 +145,35 @@ test_expect_success 'grep respects not-binary diff attribute' '
test_cmp expect actual
'
+cat >nul_to_q_textconv <<'EOF'
+#!/bin/sh
+"$PERL_PATH" -pe 'y/\000/Q/' < "$1"
+EOF
+chmod +x nul_to_q_textconv
+
+test_expect_success 'setup textconv filters' '
+ echo a diff=foo >.gitattributes &&
+ git config diff.foo.textconv "\"$(pwd)\""/nul_to_q_textconv
+'
+
+test_expect_success 'grep does not honor textconv' '
+ test_must_fail git grep Qfile
+'
+
+test_expect_failure 'grep --textconv honors textconv' '
+ echo "a:binaryQfile" >expect &&
+ git grep --textconv Qfile >actual &&
+ test_cmp expect actual
+'
+
+test_expect_success 'grep --no-textconv does not honor textconv' '
+ test_must_fail git grep --no-textconv Qfile
+'
+
+test_expect_failure 'grep --textconv blob honors textconv' '
+ echo "HEAD:a:binaryQfile" >expect &&
+ git grep --textconv Qfile HEAD:a >actual &&
+ test_cmp expect actual
+'
+
test_done