]>
git.ipfire.org Git - thirdparty/git.git/blob - t/t8007-cat-file-textconv.sh
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 test_ln_s_add one.bin symlink.bin &&
17 GIT_AUTHOR_NAME=Number1 git commit -a -m First --date="2010-01-01 18:00:00" &&
18 echo "bin: test version 2" >one.bin &&
19 GIT_AUTHOR_NAME=Number2 git commit -a -m Second --date="2010-01-01 20:00:00"
22 test_expect_success
'usage: <bad rev>' '
23 cat >expect <<-\EOF &&
24 fatal: Not a valid object name HEAD2
26 test_must_fail git cat-file --textconv HEAD2 2>actual &&
27 test_cmp expect actual
30 test_expect_success
'usage: <bad rev>:<bad path>' '
31 cat >expect <<-\EOF &&
32 fatal: invalid object name '\''HEAD2'\''.
34 test_must_fail git cat-file --textconv HEAD2:two.bin 2>actual &&
35 test_cmp expect actual
38 test_expect_success
'usage: <rev>:<bad path>' '
39 cat >expect <<-\EOF &&
40 fatal: path '\''two.bin'\'' does not exist in '\''HEAD'\''
42 test_must_fail git cat-file --textconv HEAD:two.bin 2>actual &&
43 test_cmp expect actual
47 test_expect_success
'usage: <rev> with no <path>' '
48 cat >expect <<-\EOF &&
49 fatal: <object>:<path> required, only <object> '\''HEAD'\'' given
51 test_must_fail git cat-file --textconv HEAD 2>actual &&
52 test_cmp expect actual
56 test_expect_success
'usage: <bad rev>:<good (in HEAD) path>' '
57 cat >expect <<-\EOF &&
58 fatal: invalid object name '\''HEAD2'\''.
60 test_must_fail git cat-file --textconv HEAD2:one.bin 2>actual &&
61 test_cmp expect actual
68 test_expect_success
'no filter specified' '
69 git cat-file --textconv :one.bin >result &&
70 test_cmp expected result
73 test_expect_success
'setup textconv filters' '
74 echo "*.bin diff=test" >.gitattributes &&
75 git config diff.test.textconv ./helper &&
76 git config diff.test.cachetextconv false
79 test_expect_success
'cat-file without --textconv' '
80 git cat-file blob :one.bin >result &&
81 test_cmp expected result
88 test_expect_success
'cat-file without --textconv on previous commit' '
89 git cat-file -p HEAD^:one.bin >result &&
90 test_cmp expected result
94 converted: test version 2
97 test_expect_success
'cat-file --textconv on last commit' '
98 git cat-file --textconv :one.bin >result &&
99 test_cmp expected result
106 test_expect_success
'cat-file --textconv on previous commit' '
107 git cat-file --textconv HEAD^:one.bin >result &&
108 test_cmp expected result
111 test_expect_success
'cat-file without --textconv (symlink)' '
112 printf "%s" "one.bin" >expected &&
113 git cat-file blob :symlink.bin >result &&
114 test_cmp expected result
118 test_expect_success
'cat-file --textconv on index (symlink)' '
119 git cat-file --textconv :symlink.bin >result &&
120 test_cmp expected result
123 test_expect_success
'cat-file --textconv on HEAD (symlink)' '
124 git cat-file --textconv HEAD:symlink.bin >result &&
125 test_cmp expected result