Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/git/blob/master/t/t4042-diff-textconv-caching.sh # git [Ported from github.com/git/git] Sync with Git 2.56.1 Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `master` Branches Tags History `git / t / t4042-diff-textconv-caching.sh` 152 lines ยท 3694 bytes Raw Blame History 1 #!/bin/sh 2 3 test_description='test textconv caching' 4 5 . ./test-lib.sh 6 7 cat >helper <<'EOF' 8 #!/bin/sh 9 sed 's/^/converted: /' "$@" >helper.out 10 cat helper.out 11 EOF 12 chmod +x helper 13 14 test_expect_success 'setup' ' 15 echo foo content 1 >foo.bin && 16 echo bar content 1 >bar.bin && 17 git add . && 18 git commit -m one && 19 foo1=$(git rev-parse --short HEAD:foo.bin) && 20 bar1=$(git rev-parse --short HEAD:bar.bin) && 21 echo foo content 2 >foo.bin && 22 echo bar content 2 >bar.bin && 23 git commit -a -m two && 24 foo2=$(git rev-parse --short HEAD:foo.bin) && 25 bar2=$(git rev-parse --short HEAD:bar.bin) && 26 echo "*.bin diff=magic" >.gitattributes && 27 git config diff.magic.textconv ./helper && 28 git config diff.magic.cachetextconv true 29 ' 30 31 cat >expect <actual && 50 test_cmp expect actual 51 ' 52 53 test_expect_success 'cached textconv produces same output' ' 54 git diff HEAD^ HEAD >actual && 55 test_cmp expect actual 56 ' 57 58 test_expect_success 'cached textconv does not run helper' ' 59 rm -f helper.out && 60 git diff HEAD^ HEAD >actual && 61 test_cmp expect actual && 62 ! test -r helper.out 63 ' 64 65 cat >expect <other && 85 git config diff.magic.textconv "./helper other" && 86 git diff HEAD^ HEAD >actual && 87 test_cmp expect actual 88 ' 89 90 cat >expect <>.gitattributes && 110 git diff HEAD^ HEAD >actual && 111 test_cmp expect actual 112 ' 113 114 # The point here is to test that we can log the notes cache and still use it to 115 # produce a diff later (older versions of git would segfault on this). It's 116 # much more likely to come up in the real world with "log --all -p", but using 117 # --no-walk lets us reliably reproduce the order of traversal. 118 test_expect_success 'log notes cache and still use cache for -p' ' 119 git log --no-walk -p refs/notes/textconv/magic HEAD 120 ' 121 122 test_expect_success 'caching is silently ignored outside repo' ' 123 test_oid_cache <<-\EOM && 124 oid1 sha1:`5626abf` 125 oid1 sha256:`a4ed1f3` 126 oid2 sha1:`f719efd` 127 oid2 sha256:`aa9e7dc` 128 EOM 129 oid1=$(test_oid --hash=builtin oid1) && 130 oid2=$(test_oid --hash=builtin oid2) && 131 mkdir -p non-repo && 132 echo one >non-repo/one && 133 echo two >non-repo/two && 134 echo "* diff=test" >attr && 135 test_expect_code 1 \ 136 nongit git -c core.attributesFile="$PWD/attr" \ 137 -c diff.test.textconv="tr a-z A-Z <" \ 138 -c diff.test.cachetextconv=true \ 139 diff --no-index one two >actual && 140 cat >expect <<-EOF && 141 diff --git a/one b/two 142 index $oid1..$oid2 100644 143 --- a/one 144 +++ b/two 145 @@ -1 +1 @@ 146 -ONE 147 +TWO 148 EOF 149 test_cmp expect actual 150 ' 151 152 test_done