Skip to content

Commit 34bb92e

Browse files
Clément Poulaingitster
authored andcommitted
t/t8007: test textconv support for cat-file
Test the correct functionning of textconv with cat-file <sha1:blob> and cat-file HEAD^ <file>. Test the case when no driver is specified Signed-off-by: Clément Poulain <[email protected]> Signed-off-by: Diane Gasselin <[email protected]> Signed-off-by: Axel Bonnet <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent e5fba60 commit 34bb92e

File tree

1 file changed

+70
-0
lines changed

1 file changed

+70
-0
lines changed

t/t8007-cat-file-textconv.sh

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
#!/bin/sh
2+
3+
test_description='git cat-file textconv support'
4+
. ./test-lib.sh
5+
6+
cat >helper <<'EOF'
7+
#!/bin/sh
8+
sed 's/^/converted: /' "$@"
9+
EOF
10+
chmod +x helper
11+
12+
test_expect_success 'setup ' '
13+
echo test >one.bin &&
14+
git add . &&
15+
GIT_AUTHOR_NAME=Number1 git commit -a -m First --date="2010-01-01 18:00:00" &&
16+
echo test version 2 >one.bin &&
17+
GIT_AUTHOR_NAME=Number2 git commit -a -m Second --date="2010-01-01 20:00:00"
18+
'
19+
20+
cat >expected <<EOF
21+
fatal: git cat-file --textconv: unable to run textconv on :one.bin
22+
EOF
23+
24+
test_expect_success 'no filter specified' '
25+
git cat-file --textconv :one.bin 2>result
26+
test_cmp expected result
27+
'
28+
29+
test_expect_success 'setup textconv filters' '
30+
echo "*.bin diff=test" >.gitattributes &&
31+
git config diff.test.textconv ./helper &&
32+
git config diff.test.cachetextconv false
33+
'
34+
35+
cat >expected <<EOF
36+
test version 2
37+
EOF
38+
39+
test_expect_success 'cat-file without --textconv' '
40+
git cat-file blob :one.bin >result &&
41+
test_cmp expected result
42+
'
43+
44+
cat >expected <<EOF
45+
test
46+
EOF
47+
48+
test_expect_success 'cat-file without --textconv on previous commit' '
49+
git cat-file -p HEAD^:one.bin >result &&
50+
test_cmp expected result
51+
'
52+
53+
cat >expected <<EOF
54+
converted: test version 2
55+
EOF
56+
57+
test_expect_success 'cat-file --textconv on last commit' '
58+
git cat-file --textconv :one.bin >result &&
59+
test_cmp expected result
60+
'
61+
62+
cat >expected <<EOF
63+
converted: test
64+
EOF
65+
66+
test_expect_success 'cat-file --textconv on previous commit' '
67+
git cat-file --textconv HEAD^:one.bin >result &&
68+
test_cmp expected result
69+
'
70+
test_done

0 commit comments

Comments
 (0)