replace has_extension with ends_with
[git/mingw.git] / t / t8007-cat-file-textconv.sh
blobeacd49ade636f5be6166e05d4e200b9a324073be
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 test_ln_s_add one.bin symlink.bin &&
16 git add . &&
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 cat >expected <<EOF
23 bin: test version 2
24 EOF
26 test_expect_success 'no filter specified' '
27 git cat-file --textconv :one.bin >result &&
28 test_cmp expected result
31 test_expect_success 'setup textconv filters' '
32 echo "*.bin diff=test" >.gitattributes &&
33 git config diff.test.textconv ./helper &&
34 git config diff.test.cachetextconv false
37 test_expect_success 'cat-file without --textconv' '
38 git cat-file blob :one.bin >result &&
39 test_cmp expected result
42 cat >expected <<EOF
43 bin: test
44 EOF
46 test_expect_success 'cat-file without --textconv on previous commit' '
47 git cat-file -p HEAD^:one.bin >result &&
48 test_cmp expected result
51 cat >expected <<EOF
52 converted: test version 2
53 EOF
55 test_expect_success 'cat-file --textconv on last commit' '
56 git cat-file --textconv :one.bin >result &&
57 test_cmp expected result
60 cat >expected <<EOF
61 converted: test
62 EOF
64 test_expect_success 'cat-file --textconv on previous commit' '
65 git cat-file --textconv HEAD^:one.bin >result &&
66 test_cmp expected result
69 test_expect_success 'cat-file without --textconv (symlink)' '
70 printf "%s" "one.bin" >expected &&
71 git cat-file blob :symlink.bin >result &&
72 test_cmp expected result
76 test_expect_success 'cat-file --textconv on index (symlink)' '
77 git cat-file --textconv :symlink.bin >result &&
78 test_cmp expected result
81 test_expect_success 'cat-file --textconv on HEAD (symlink)' '
82 git cat-file --textconv HEAD:symlink.bin >result &&
83 test_cmp expected result
86 test_done