interplane.Get Omega
Read in your language

git

[Ported from github.com/git/git] Sync with Git 2.56.1

Brought by drakestapleton

branch master Branches Tags History

git / t / t8010-cat-file-filters.sh

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