git-svn: support for git-svn propset
[gitweb.git] / t / t7008-grep-binary.sh
index fd6410fc7149ed381d4d09120089859281e40696..b146406e9c0912cdeb1a9c5bc93d41b981e971ca 100755 (executable)
@@ -111,6 +111,28 @@ test_expect_success 'grep respects binary diff attribute' '
        test_cmp expect actual
 '
 
+test_expect_success 'grep --cached respects binary diff attribute' '
+       git grep --cached text t >actual &&
+       test_cmp expect actual
+'
+
+test_expect_success 'grep --cached respects binary diff attribute (2)' '
+       git add .gitattributes &&
+       rm .gitattributes &&
+       git grep --cached text t >actual &&
+       test_when_finished "git rm --cached .gitattributes" &&
+       test_when_finished "git checkout .gitattributes" &&
+       test_cmp expect actual
+'
+
+test_expect_success 'grep revision respects binary diff attribute' '
+       git commit -m new &&
+       echo "Binary file HEAD:t matches" >expect &&
+       git grep text HEAD -- t >actual &&
+       test_when_finished "git reset HEAD^" &&
+       test_cmp expect actual
+'
+
 test_expect_success 'grep respects not-binary diff attribute' '
        echo binQary | q_to_nul >b &&
        git add b &&
@@ -123,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_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
+'
+
 test_done