ref-filter: make remote_ref_atom_parser() use refname_atom_parser_internal()
[gitweb.git] / t / t7008-grep-binary.sh
index 26f831984d603a959e2141641269268a2f0d78c8..9c9c378119defa7884a21beb27e806ddf1171497 100755 (executable)
@@ -141,7 +141,39 @@ test_expect_success 'grep respects not-binary diff attribute' '
        test_cmp expect actual &&
        echo "b diff" >.gitattributes &&
        echo "b:binQary" >expect &&
-       git grep bin b | nul_to_q >actual &&
+       git grep bin b >actual.raw &&
+       nul_to_q <actual.raw >actual &&
+       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_success '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_success 'grep --textconv blob honors textconv' '
+       echo "HEAD:a:binaryQfile" >expect &&
+       git grep --textconv Qfile HEAD:a >actual &&
        test_cmp expect actual
 '