3 test_description='git cat-file filters support'
6 test_expect_success 'setup ' '
7 echo "*.txt eol=crlf diff=txt" >.gitattributes &&
8 echo "hello" | append_cr >world.txt &&
9 git add .gitattributes world.txt &&
11 git commit -m "Initial commit"
15 tr '\015' Q <"$1" | grep Q >/dev/null
18 test_expect_success 'no filters with `git show`' '
19 git show HEAD:world.txt >actual &&
24 test_expect_success 'no filters with cat-file' '
25 git cat-file blob HEAD:world.txt >actual &&
29 test_expect_success 'cat-file --filters converts to worktree version' '
30 git cat-file --filters HEAD:world.txt >actual &&
34 test_expect_success 'cat-file --filters --path=<path> works' '
35 sha1=$(git rev-parse -q --verify HEAD:world.txt) &&
36 git cat-file --filters --path=world.txt $sha1 >actual &&
40 test_expect_success 'cat-file --textconv --path=<path> works' '
41 sha1=$(git rev-parse -q --verify HEAD:world.txt) &&
42 test_config diff.txt.textconv "tr A-Za-z N-ZA-Mn-za-m <" &&
43 git cat-file --textconv --path=hello.txt $sha1 >rot13 &&
44 test uryyb = "$(cat rot13 | remove_cr)"
47 test_expect_success '--path=<path> complains without --textconv/--filters' '
48 sha1=$(git rev-parse -q --verify HEAD:world.txt) &&
49 test_must_fail git cat-file --path=hello.txt blob $sha1 >actual 2>err &&
51 grep "path.*needs.*filters" err
54 test_expect_success 'cat-file --textconv --batch works' '
55 sha1=$(git rev-parse -q --verify HEAD:world.txt) &&
56 test_config diff.txt.textconv "tr A-Za-z N-ZA-Mn-za-m <" &&
57 printf "%s hello.txt\n%s hello\n" $sha1 $sha1 |
58 git cat-file --textconv --batch >actual &&
59 printf "%s blob 6\nuryyb\r\n\n%s blob 6\nhello\n\n" \
60 $sha1 $sha1 >expect &&
61 test_cmp expect actual