]> git.ipfire.org Git - thirdparty/git.git/blame - t/t8007-cat-file-textconv.sh
path.c: don't call the match function without value in trie_find()
[thirdparty/git.git] / t / t8007-cat-file-textconv.sh
CommitLineData
34bb92ec
CP
1#!/bin/sh
2
3test_description='git cat-file textconv support'
4. ./test-lib.sh
5
6cat >helper <<'EOF'
7#!/bin/sh
6517cf7d
KS
8grep -q '^bin: ' "$1" || { echo "E: $1 is not \"binary\" file" 1>&2; exit 1; }
9sed 's/^bin: /converted: /' "$1"
34bb92ec
CP
10EOF
11chmod +x helper
12
13test_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
22cat >expected <<EOF
3ac21617 23bin: test version 2
34bb92ec
CP
24EOF
25
26test_expect_success 'no filter specified' '
3ac21617 27 git cat-file --textconv :one.bin >result &&
34bb92ec
CP
28 test_cmp expected result
29'
30
31test_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
37test_expect_success 'cat-file without --textconv' '
38 git cat-file blob :one.bin >result &&
39 test_cmp expected result
40'
41
42cat >expected <<EOF
6517cf7d 43bin: test
34bb92ec
CP
44EOF
45
46test_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
51cat >expected <<EOF
52converted: test version 2
53EOF
54
55test_expect_success 'cat-file --textconv on last commit' '
56 git cat-file --textconv :one.bin >result &&
57 test_cmp expected result
58'
59
60cat >expected <<EOF
61converted: test
62EOF
63
64test_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 69test_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 76test_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 81test_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 86test_done