cat-file: do not die on --textconv without textconv filters
[git/mingw/j6t.git] / t / t8007-cat-file-textconv.sh
blob83c663678f5700f994da1508dbfb4529597b751d
1 #!/bin/sh
3 test_description='git cat-file textconv support'
4 . ./test-lib.sh
6 cat >helper <<'EOF'
7 #!/bin/sh
8 grep -q '^bin: ' "$1" || { echo "E: $1 is not \"binary\" file" 1>&2; exit 1; }
9 sed 's/^bin: /converted: /' "$1"
10 EOF
11 chmod +x helper
13 test_expect_success 'setup ' '
14 echo "bin: test" >one.bin &&
15 if test_have_prereq SYMLINKS; then
16 ln -s one.bin symlink.bin
17 fi &&
18 git add . &&
19 GIT_AUTHOR_NAME=Number1 git commit -a -m First --date="2010-01-01 18:00:00" &&
20 echo "bin: test version 2" >one.bin &&
21 GIT_AUTHOR_NAME=Number2 git commit -a -m Second --date="2010-01-01 20:00:00"
24 cat >expected <<EOF
25 bin: test version 2
26 EOF
28 test_expect_success 'no filter specified' '
29 git cat-file --textconv :one.bin >result &&
30 test_cmp expected result
33 test_expect_success 'setup textconv filters' '
34 echo "*.bin diff=test" >.gitattributes &&
35 git config diff.test.textconv ./helper &&
36 git config diff.test.cachetextconv false
39 test_expect_success 'cat-file without --textconv' '
40 git cat-file blob :one.bin >result &&
41 test_cmp expected result
44 cat >expected <<EOF
45 bin: test
46 EOF
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
53 cat >expected <<EOF
54 converted: test version 2
55 EOF
57 test_expect_success 'cat-file --textconv on last commit' '
58 git cat-file --textconv :one.bin >result &&
59 test_cmp expected result
62 cat >expected <<EOF
63 converted: test
64 EOF
66 test_expect_success 'cat-file --textconv on previous commit' '
67 git cat-file --textconv HEAD^:one.bin >result &&
68 test_cmp expected result
71 test_expect_success SYMLINKS 'cat-file without --textconv (symlink)' '
72 printf "%s" "one.bin" >expected &&
73 git cat-file blob :symlink.bin >result &&
74 test_cmp expected result
78 test_expect_success SYMLINKS 'cat-file --textconv on index (symlink)' '
79 git cat-file --textconv :symlink.bin >result &&
80 test_cmp expected result
83 test_expect_success SYMLINKS 'cat-file --textconv on HEAD (symlink)' '
84 git cat-file --textconv HEAD:symlink.bin >result &&
85 test_cmp expected result
88 test_done