3 test_description
='git cat-file textconv support'
5 TEST_PASSES_SANITIZE_LEAK
=true
10 grep -q '^bin: ' "$1" || { echo "E: $1 is not \"binary\" file" 1>&2; exit 1; }
11 sed 's/^bin: /converted: /' "$1"
15 test_expect_success
'setup ' '
16 echo "bin: test" >one.bin &&
17 test_ln_s_add 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"
24 test_expect_success
'usage: <bad rev>' '
25 cat >expect <<-\EOF &&
26 fatal: Not a valid object name HEAD2
28 test_must_fail git cat-file --textconv HEAD2 2>actual &&
29 test_cmp expect actual
32 test_expect_success
'usage: <bad rev>:<bad path>' '
33 cat >expect <<-\EOF &&
34 fatal: invalid object name '\''HEAD2'\''.
36 test_must_fail git cat-file --textconv HEAD2:two.bin 2>actual &&
37 test_cmp expect actual
40 test_expect_success
'usage: <rev>:<bad path>' '
41 cat >expect <<-\EOF &&
42 fatal: path '\''two.bin'\'' does not exist in '\''HEAD'\''
44 test_must_fail git cat-file --textconv HEAD:two.bin 2>actual &&
45 test_cmp expect actual
49 test_expect_success
'usage: <rev> with no <path>' '
50 cat >expect <<-\EOF &&
51 fatal: <object>:<path> required, only <object> '\''HEAD'\'' given
53 test_must_fail git cat-file --textconv HEAD 2>actual &&
54 test_cmp expect actual
58 test_expect_success
'usage: <bad rev>:<good (in HEAD) path>' '
59 cat >expect <<-\EOF &&
60 fatal: invalid object name '\''HEAD2'\''.
62 test_must_fail git cat-file --textconv HEAD2:one.bin 2>actual &&
63 test_cmp expect actual
70 test_expect_success
'no filter specified' '
71 git cat-file --textconv :one.bin >result &&
72 test_cmp expected result
75 test_expect_success
'setup textconv filters' '
76 echo "*.bin diff=test" >.gitattributes &&
77 git config diff.test.textconv ./helper &&
78 git config diff.test.cachetextconv false
81 test_expect_success
'cat-file without --textconv' '
82 git cat-file blob :one.bin >result &&
83 test_cmp expected result
90 test_expect_success
'cat-file without --textconv on previous commit' '
91 git cat-file -p HEAD^:one.bin >result &&
92 test_cmp expected result
96 converted: test version 2
99 test_expect_success
'cat-file --textconv on last commit' '
100 git cat-file --textconv :one.bin >result &&
101 test_cmp expected result
108 test_expect_success
'cat-file --textconv on previous commit' '
109 git cat-file --textconv HEAD^:one.bin >result &&
110 test_cmp expected result
113 test_expect_success
'cat-file without --textconv (symlink)' '
114 printf "%s" "one.bin" >expected &&
115 git cat-file blob :symlink.bin >result &&
116 test_cmp expected result
120 test_expect_success
'cat-file --textconv on index (symlink)' '
121 git cat-file --textconv :symlink.bin >result &&
122 test_cmp expected result
125 test_expect_success
'cat-file --textconv on HEAD (symlink)' '
126 git cat-file --textconv HEAD:symlink.bin >result &&
127 test_cmp expected result