3 test_description='test textconv caching'
8 sed 's/^/converted: /' "$@" >helper.out
13 test_expect_success 'setup' '
14 echo foo content 1 >foo.bin &&
15 echo bar content 1 >bar.bin &&
18 foo1=$(git rev-parse --short HEAD:foo.bin) &&
19 bar1=$(git rev-parse --short HEAD:bar.bin) &&
20 echo foo content 2 >foo.bin &&
21 echo bar content 2 >bar.bin &&
22 git commit -a -m two &&
23 foo2=$(git rev-parse --short HEAD:foo.bin) &&
24 bar2=$(git rev-parse --short HEAD:bar.bin) &&
25 echo "*.bin diff=magic" >.gitattributes &&
26 git config diff.magic.textconv ./helper &&
27 git config diff.magic.cachetextconv true
31 diff --git a/bar.bin b/bar.bin
32 index $bar1..$bar2 100644
36 -converted: bar content 1
37 +converted: bar content 2
38 diff --git a/foo.bin b/foo.bin
39 index $foo1..$foo2 100644
43 -converted: foo content 1
44 +converted: foo content 2
47 test_expect_success 'first textconv works' '
48 git diff HEAD^ HEAD >actual &&
49 test_cmp expect actual
52 test_expect_success 'cached textconv produces same output' '
53 git diff HEAD^ HEAD >actual &&
54 test_cmp expect actual
57 test_expect_success 'cached textconv does not run helper' '
59 git diff HEAD^ HEAD >actual &&
60 test_cmp expect actual &&
65 diff --git a/bar.bin b/bar.bin
66 index $bar1..$bar2 100644
71 -converted: bar content 1
72 +converted: bar content 2
73 diff --git a/foo.bin b/foo.bin
74 index $foo1..$foo2 100644
79 -converted: foo content 1
80 +converted: foo content 2
82 test_expect_success 'changing textconv invalidates cache' '
84 git config diff.magic.textconv "./helper other" &&
85 git diff HEAD^ HEAD >actual &&
86 test_cmp expect actual
90 diff --git a/bar.bin b/bar.bin
91 index $bar1..$bar2 100644
96 -converted: bar content 1
97 +converted: bar content 2
98 diff --git a/foo.bin b/foo.bin
99 index $foo1..$foo2 100644
103 -converted: foo content 1
104 +converted: foo content 2
106 test_expect_success 'switching diff driver produces correct results' '
107 git config diff.moremagic.textconv ./helper &&
108 echo foo.bin diff=moremagic >>.gitattributes &&
109 git diff HEAD^ HEAD >actual &&
110 test_cmp expect actual
113 # The point here is to test that we can log the notes cache and still use it to
114 # produce a diff later (older versions of git would segfault on this). It's
115 # much more likely to come up in the real world with "log --all -p", but using
116 # --no-walk lets us reliably reproduce the order of traversal.
117 test_expect_success 'log notes cache and still use cache for -p' '
118 git log --no-walk -p refs/notes/textconv/magic HEAD