3 test_description='git cat-file textconv support'
8 grep -q '^bin: ' "$1" || { echo "E: $1 is not \"binary\" file" 1>&2; exit 1; }
9 sed 's/^bin: /converted: /' "$1"
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
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"
25 fatal: git cat-file --textconv: unable to run textconv on :one.bin
28 test_expect_success 'no filter specified' '
29 git cat-file --textconv :one.bin 2>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
43 test_expect_success 'cat-file without --textconv' '
44 git cat-file blob :one.bin >result &&
45 test_cmp expected result
52 test_expect_success 'cat-file without --textconv on previous commit' '
53 git cat-file -p HEAD^:one.bin >result &&
54 test_cmp expected result
58 converted: test version 2
61 test_expect_success 'cat-file --textconv on last commit' '
62 git cat-file --textconv :one.bin >result &&
63 test_cmp expected result
70 test_expect_success 'cat-file --textconv on previous commit' '
71 git cat-file --textconv HEAD^:one.bin >result &&
72 test_cmp expected result
75 test_expect_success SYMLINKS 'cat-file without --textconv (symlink)' '
76 git cat-file blob :symlink.bin >result &&
77 printf "%s" "one.bin" >expected
78 test_cmp expected result
82 test_expect_success SYMLINKS 'cat-file --textconv on index (symlink)' '
83 ! git cat-file --textconv :symlink.bin 2>result &&
84 cat >expected <<\EOF &&
85 fatal: git cat-file --textconv: unable to run textconv on :symlink.bin
87 test_cmp expected result
90 test_expect_success SYMLINKS 'cat-file --textconv on HEAD (symlink)' '
91 ! git cat-file --textconv HEAD:symlink.bin 2>result &&
92 cat >expected <<EOF &&
93 fatal: git cat-file --textconv: unable to run textconv on HEAD:symlink.bin
95 test_cmp expected result