]>
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 && |
889c6f0e | 15 | test_ln_s_add one.bin symlink.bin && |
34bb92ec CP |
16 | git add . && |
17 | GIT_AUTHOR_NAME=Number1 git commit -a -m First --date="2010-01-01 18:00:00" && | |
6517cf7d | 18 | echo "bin: test version 2" >one.bin && |
34bb92ec CP |
19 | GIT_AUTHOR_NAME=Number2 git commit -a -m Second --date="2010-01-01 20:00:00" |
20 | ' | |
21 | ||
22 | cat >expected <<EOF | |
3ac21617 | 23 | bin: test version 2 |
34bb92ec CP |
24 | EOF |
25 | ||
26 | test_expect_success 'no filter specified' ' | |
3ac21617 | 27 | git cat-file --textconv :one.bin >result && |
34bb92ec CP |
28 | test_cmp expected result |
29 | ' | |
30 | ||
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 | |
35 | ' | |
36 | ||
34bb92ec CP |
37 | test_expect_success 'cat-file without --textconv' ' |
38 | git cat-file blob :one.bin >result && | |
39 | test_cmp expected result | |
40 | ' | |
41 | ||
42 | cat >expected <<EOF | |
6517cf7d | 43 | bin: test |
34bb92ec CP |
44 | EOF |
45 | ||
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 | |
49 | ' | |
50 | ||
51 | cat >expected <<EOF | |
52 | converted: test version 2 | |
53 | EOF | |
54 | ||
55 | test_expect_success 'cat-file --textconv on last commit' ' | |
56 | git cat-file --textconv :one.bin >result && | |
57 | test_cmp expected result | |
58 | ' | |
59 | ||
60 | cat >expected <<EOF | |
61 | converted: test | |
62 | EOF | |
63 | ||
64 | test_expect_success 'cat-file --textconv on previous commit' ' | |
65 | git cat-file --textconv HEAD^:one.bin >result && | |
66 | test_cmp expected result | |
67 | ' | |
ab3b7b9a | 68 | |
889c6f0e | 69 | test_expect_success 'cat-file without --textconv (symlink)' ' |
3ac21617 | 70 | printf "%s" "one.bin" >expected && |
ab3b7b9a | 71 | git cat-file blob :symlink.bin >result && |
ab3b7b9a KS |
72 | test_cmp expected result |
73 | ' | |
74 | ||
75 | ||
889c6f0e | 76 | test_expect_success 'cat-file --textconv on index (symlink)' ' |
3ac21617 | 77 | git cat-file --textconv :symlink.bin >result && |
ab3b7b9a KS |
78 | test_cmp expected result |
79 | ' | |
80 | ||
889c6f0e | 81 | test_expect_success 'cat-file --textconv on HEAD (symlink)' ' |
3ac21617 | 82 | git cat-file --textconv HEAD:symlink.bin >result && |
ab3b7b9a KS |
83 | test_cmp expected result |
84 | ' | |
85 | ||
34bb92ec | 86 | test_done |