Skip to content

Commit 97f6a9c

Browse files
Michael J Grubergitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 3ac2161 commit 97f6a9c

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

t/t7008-grep-binary.sh

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,4 +145,35 @@ test_expect_success 'grep respects not-binary diff attribute' '
145145
test_cmp expect actual
146146
'
147147

148+
cat >nul_to_q_textconv <<'EOF'
149+
#!/bin/sh
150+
"$PERL_PATH" -pe 'y/\000/Q/' < "$1"
151+
EOF
152+
chmod +x nul_to_q_textconv
153+
154+
test_expect_success 'setup textconv filters' '
155+
echo a diff=foo >.gitattributes &&
156+
git config diff.foo.textconv "\"$(pwd)\""/nul_to_q_textconv
157+
'
158+
159+
test_expect_success 'grep does not honor textconv' '
160+
test_must_fail git grep Qfile
161+
'
162+
163+
test_expect_failure 'grep --textconv honors textconv' '
164+
echo "a:binaryQfile" >expect &&
165+
git grep --textconv Qfile >actual &&
166+
test_cmp expect actual
167+
'
168+
169+
test_expect_success 'grep --no-textconv does not honor textconv' '
170+
test_must_fail git grep --no-textconv Qfile
171+
'
172+
173+
test_expect_failure 'grep --textconv blob honors textconv' '
174+
echo "HEAD:a:binaryQfile" >expect &&
175+
git grep --textconv Qfile HEAD:a >actual &&
176+
test_cmp expect actual
177+
'
178+
148179
test_done

0 commit comments

Comments
 (0)