blame,cat-file: Prepare --textconv tests for correctly-failing conversion program
[git/kirr.git] / t / t8007-cat-file-textconv.sh
blob71f41453d1c4cfcaaba7642447dda0a912c15e1f
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 git add . &&
16 GIT_AUTHOR_NAME=Number1 git commit -a -m First --date="2010-01-01 18:00:00" &&
17 echo "bin: test version 2" >one.bin &&
18 GIT_AUTHOR_NAME=Number2 git commit -a -m Second --date="2010-01-01 20:00:00"
21 cat >expected <<EOF
22 fatal: git cat-file --textconv: unable to run textconv on :one.bin
23 EOF
25 test_expect_success 'no filter specified' '
26 git cat-file --textconv :one.bin 2>result
27 test_cmp expected result
30 test_expect_success 'setup textconv filters' '
31 echo "*.bin diff=test" >.gitattributes &&
32 git config diff.test.textconv ./helper &&
33 git config diff.test.cachetextconv false
36 cat >expected <<EOF
37 bin: test version 2
38 EOF
40 test_expect_success 'cat-file without --textconv' '
41 git cat-file blob :one.bin >result &&
42 test_cmp expected result
45 cat >expected <<EOF
46 bin: test
47 EOF
49 test_expect_success 'cat-file without --textconv on previous commit' '
50 git cat-file -p HEAD^:one.bin >result &&
51 test_cmp expected result
54 cat >expected <<EOF
55 converted: test version 2
56 EOF
58 test_expect_success 'cat-file --textconv on last commit' '
59 git cat-file --textconv :one.bin >result &&
60 test_cmp expected result
63 cat >expected <<EOF
64 converted: test
65 EOF
67 test_expect_success 'cat-file --textconv on previous commit' '
68 git cat-file --textconv HEAD^:one.bin >result &&
69 test_cmp expected result
71 test_done