]>
Commit | Line | Data |
---|---|---|
b9e62f60 JS |
1 | #!/bin/sh |
2 | ||
3 | test_description='git cat-file filters support' | |
27472b51 ÆAB |
4 | |
5 | TEST_PASSES_SANITIZE_LEAK=true | |
b9e62f60 JS |
6 | . ./test-lib.sh |
7 | ||
8 | test_expect_success 'setup ' ' | |
9 | echo "*.txt eol=crlf diff=txt" >.gitattributes && | |
10 | echo "hello" | append_cr >world.txt && | |
11 | git add .gitattributes world.txt && | |
12 | test_tick && | |
13 | git commit -m "Initial commit" | |
14 | ' | |
15 | ||
16 | has_cr () { | |
17 | tr '\015' Q <"$1" | grep Q >/dev/null | |
18 | } | |
19 | ||
20 | test_expect_success 'no filters with `git show`' ' | |
21 | git show HEAD:world.txt >actual && | |
22 | ! has_cr actual | |
23 | ||
24 | ' | |
25 | ||
26 | test_expect_success 'no filters with cat-file' ' | |
27 | git cat-file blob HEAD:world.txt >actual && | |
28 | ! has_cr actual | |
29 | ' | |
30 | ||
31 | test_expect_success 'cat-file --filters converts to worktree version' ' | |
32 | git cat-file --filters HEAD:world.txt >actual && | |
33 | has_cr actual | |
34 | ' | |
35 | ||
7bcf3414 JS |
36 | test_expect_success 'cat-file --filters --path=<path> works' ' |
37 | sha1=$(git rev-parse -q --verify HEAD:world.txt) && | |
38 | git cat-file --filters --path=world.txt $sha1 >actual && | |
39 | has_cr actual | |
40 | ' | |
41 | ||
42 | test_expect_success 'cat-file --textconv --path=<path> works' ' | |
43 | sha1=$(git rev-parse -q --verify HEAD:world.txt) && | |
44 | test_config diff.txt.textconv "tr A-Za-z N-ZA-Mn-za-m <" && | |
45 | git cat-file --textconv --path=hello.txt $sha1 >rot13 && | |
46 | test uryyb = "$(cat rot13 | remove_cr)" | |
47 | ' | |
48 | ||
49 | test_expect_success '--path=<path> complains without --textconv/--filters' ' | |
50 | sha1=$(git rev-parse -q --verify HEAD:world.txt) && | |
51 | test_must_fail git cat-file --path=hello.txt blob $sha1 >actual 2>err && | |
f0dc593a | 52 | test_must_be_empty actual && |
7bcf3414 JS |
53 | grep "path.*needs.*filters" err |
54 | ' | |
55 | ||
cc0ea7c9 JK |
56 | test_expect_success '--textconv/--filters complain without path' ' |
57 | test_must_fail git cat-file --textconv HEAD && | |
58 | test_must_fail git cat-file --filters HEAD | |
59 | ' | |
60 | ||
32145943 JS |
61 | test_expect_success 'cat-file --textconv --batch works' ' |
62 | sha1=$(git rev-parse -q --verify HEAD:world.txt) && | |
63 | test_config diff.txt.textconv "tr A-Za-z N-ZA-Mn-za-m <" && | |
64 | printf "%s hello.txt\n%s hello\n" $sha1 $sha1 | | |
65 | git cat-file --textconv --batch >actual && | |
66 | printf "%s blob 6\nuryyb\r\n\n%s blob 6\nhello\n\n" \ | |
67 | $sha1 $sha1 >expect && | |
68 | test_cmp expect actual | |
69 | ' | |
70 | ||
b9e62f60 | 71 | test_done |