]>
Commit | Line | Data |
---|---|---|
34bb92ec CP |
1 | #!/bin/sh |
2 | ||
3 | test_description='git cat-file textconv support' | |
4 | . ./test-lib.sh | |
5 | ||
6 | cat >helper <<'EOF' | |
7 | #!/bin/sh | |
6517cf7d KS |
8 | grep -q '^bin: ' "$1" || { echo "E: $1 is not \"binary\" file" 1>&2; exit 1; } |
9 | sed 's/^bin: /converted: /' "$1" | |
34bb92ec CP |
10 | EOF |
11 | chmod +x helper | |
12 | ||
13 | test_expect_success 'setup ' ' | |
6517cf7d | 14 | echo "bin: test" >one.bin && |
ab3b7b9a KS |
15 | if test_have_prereq SYMLINKS; then |
16 | ln -s one.bin symlink.bin | |
17 | fi && | |
34bb92ec CP |
18 | git add . && |
19 | GIT_AUTHOR_NAME=Number1 git commit -a -m First --date="2010-01-01 18:00:00" && | |
6517cf7d | 20 | echo "bin: test version 2" >one.bin && |
34bb92ec CP |
21 | GIT_AUTHOR_NAME=Number2 git commit -a -m Second --date="2010-01-01 20:00:00" |
22 | ' | |
23 | ||
24 | cat >expected <<EOF | |
25 | fatal: git cat-file --textconv: unable to run textconv on :one.bin | |
26 | EOF | |
27 | ||
28 | test_expect_success 'no filter specified' ' | |
29 | git cat-file --textconv :one.bin 2>result | |
30 | test_cmp expected result | |
31 | ' | |
32 | ||
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 | |
37 | ' | |
38 | ||
39 | cat >expected <<EOF | |
6517cf7d | 40 | bin: test version 2 |
34bb92ec CP |
41 | EOF |
42 | ||
43 | test_expect_success 'cat-file without --textconv' ' | |
44 | git cat-file blob :one.bin >result && | |
45 | test_cmp expected result | |
46 | ' | |
47 | ||
48 | cat >expected <<EOF | |
6517cf7d | 49 | bin: test |
34bb92ec CP |
50 | EOF |
51 | ||
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 | |
55 | ' | |
56 | ||
57 | cat >expected <<EOF | |
58 | converted: test version 2 | |
59 | EOF | |
60 | ||
61 | test_expect_success 'cat-file --textconv on last commit' ' | |
62 | git cat-file --textconv :one.bin >result && | |
63 | test_cmp expected result | |
64 | ' | |
65 | ||
66 | cat >expected <<EOF | |
67 | converted: test | |
68 | EOF | |
69 | ||
70 | test_expect_success 'cat-file --textconv on previous commit' ' | |
71 | git cat-file --textconv HEAD^:one.bin >result && | |
72 | test_cmp expected result | |
73 | ' | |
ab3b7b9a KS |
74 | |
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 | |
79 | ' | |
80 | ||
81 | ||
90064710 | 82 | test_expect_success SYMLINKS 'cat-file --textconv on index (symlink)' ' |
ab3b7b9a KS |
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 | |
86 | EOF | |
87 | test_cmp expected result | |
88 | ' | |
89 | ||
90064710 | 90 | test_expect_success SYMLINKS 'cat-file --textconv on HEAD (symlink)' ' |
ab3b7b9a KS |
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 | |
94 | EOF | |
95 | test_cmp expected result | |
96 | ' | |
97 | ||
34bb92ec | 98 | test_done |