Documentation: Describe "git diff <blob> <blob>" separately
[git.git] / t / t4042-diff-textconv-caching.sh
blob91f8198f058df5e2ee93cda8086793ce6a9186d5
1 #!/bin/sh
3 test_description='test textconv caching'
4 . ./test-lib.sh
6 cat >helper <<'EOF'
7 #!/bin/sh
8 sed 's/^/converted: /' "$@" >helper.out
9 cat helper.out
10 EOF
11 chmod +x helper
13 test_expect_success 'setup' '
14 echo foo content 1 >foo.bin &&
15 echo bar content 1 >bar.bin &&
16 git add . &&
17 git commit -m one &&
18 echo foo content 2 >foo.bin &&
19 echo bar content 2 >bar.bin &&
20 git commit -a -m two &&
21 echo "*.bin diff=magic" >.gitattributes &&
22 git config diff.magic.textconv ./helper &&
23 git config diff.magic.cachetextconv true
26 cat >expect <<EOF
27 diff --git a/bar.bin b/bar.bin
28 index fcf9166..28283d5 100644
29 --- a/bar.bin
30 +++ b/bar.bin
31 @@ -1 +1 @@
32 -converted: bar content 1
33 +converted: bar content 2
34 diff --git a/foo.bin b/foo.bin
35 index d5b9fe3..1345db2 100644
36 --- a/foo.bin
37 +++ b/foo.bin
38 @@ -1 +1 @@
39 -converted: foo content 1
40 +converted: foo content 2
41 EOF
43 test_expect_success 'first textconv works' '
44 git diff HEAD^ HEAD >actual &&
45 test_cmp expect actual
48 test_expect_success 'cached textconv produces same output' '
49 git diff HEAD^ HEAD >actual &&
50 test_cmp expect actual
53 test_expect_success 'cached textconv does not run helper' '
54 rm -f helper.out &&
55 git diff HEAD^ HEAD >actual &&
56 test_cmp expect actual &&
57 ! test -r helper.out
60 cat >expect <<EOF
61 diff --git a/bar.bin b/bar.bin
62 index fcf9166..28283d5 100644
63 --- a/bar.bin
64 +++ b/bar.bin
65 @@ -1,2 +1,2 @@
66 converted: other
67 -converted: bar content 1
68 +converted: bar content 2
69 diff --git a/foo.bin b/foo.bin
70 index d5b9fe3..1345db2 100644
71 --- a/foo.bin
72 +++ b/foo.bin
73 @@ -1,2 +1,2 @@
74 converted: other
75 -converted: foo content 1
76 +converted: foo content 2
77 EOF
78 test_expect_success 'changing textconv invalidates cache' '
79 echo other >other &&
80 git config diff.magic.textconv "./helper other" &&
81 git diff HEAD^ HEAD >actual &&
82 test_cmp expect actual
85 cat >expect <<EOF
86 diff --git a/bar.bin b/bar.bin
87 index fcf9166..28283d5 100644
88 --- a/bar.bin
89 +++ b/bar.bin
90 @@ -1,2 +1,2 @@
91 converted: other
92 -converted: bar content 1
93 +converted: bar content 2
94 diff --git a/foo.bin b/foo.bin
95 index d5b9fe3..1345db2 100644
96 --- a/foo.bin
97 +++ b/foo.bin
98 @@ -1 +1 @@
99 -converted: foo content 1
100 +converted: foo content 2
102 test_expect_success 'switching diff driver produces correct results' '
103 git config diff.moremagic.textconv ./helper &&
104 echo foo.bin diff=moremagic >>.gitattributes &&
105 git diff HEAD^ HEAD >actual &&
106 test_cmp expect actual
109 test_done