reftable/record: decode keys in place
[alt-git.git] / t / t4048-diff-combined-binary.sh
blob0260cf64f5d5507eb53fde74fba88d9d3a9ab3b4
1 #!/bin/sh
3 test_description='combined and merge diff handle binary files and textconv'
4 GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
5 export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
7 . ./test-lib.sh
9 test_expect_success 'setup binary merge conflict' '
10 echo oneQ1 | q_to_nul >binary &&
11 git add binary &&
12 git commit -m one &&
13 echo twoQ2 | q_to_nul >binary &&
14 git commit -a -m two &&
15 two=$(git rev-parse --short HEAD:binary) &&
16 git checkout -b branch-binary HEAD^ &&
17 echo threeQ3 | q_to_nul >binary &&
18 git commit -a -m three &&
19 three=$(git rev-parse --short HEAD:binary) &&
20 test_must_fail git merge main &&
21 echo resolvedQhooray | q_to_nul >binary &&
22 git commit -a -m resolved &&
23 res=$(git rev-parse --short HEAD:binary)
26 cat >expect <<EOF
27 resolved
29 diff --git a/binary b/binary
30 index $three..$res 100644
31 Binary files a/binary and b/binary differ
32 resolved
34 diff --git a/binary b/binary
35 index $two..$res 100644
36 Binary files a/binary and b/binary differ
37 EOF
38 test_expect_success 'diff -m indicates binary-ness' '
39 git show --format=%s -m >actual &&
40 test_cmp expect actual
43 cat >expect <<EOF
44 resolved
46 diff --combined binary
47 index $three,$two..$res
48 Binary files differ
49 EOF
50 test_expect_success 'diff -c indicates binary-ness' '
51 git show --format=%s -c >actual &&
52 test_cmp expect actual
55 cat >expect <<EOF
56 resolved
58 diff --cc binary
59 index $three,$two..$res
60 Binary files differ
61 EOF
62 test_expect_success 'diff --cc indicates binary-ness' '
63 git show --format=%s --cc >actual &&
64 test_cmp expect actual
67 test_expect_success 'setup non-binary with binary attribute' '
68 git checkout main &&
69 test_commit one text &&
70 test_commit two text &&
71 two=$(git rev-parse --short HEAD:text) &&
72 git checkout -b branch-text HEAD^ &&
73 test_commit three text &&
74 three=$(git rev-parse --short HEAD:text) &&
75 test_must_fail git merge main &&
76 test_commit resolved text &&
77 res=$(git rev-parse --short HEAD:text) &&
78 echo text -diff >.gitattributes
81 cat >expect <<EOF
82 resolved
84 diff --git a/text b/text
85 index $three..$res 100644
86 Binary files a/text and b/text differ
87 resolved
89 diff --git a/text b/text
90 index $two..$res 100644
91 Binary files a/text and b/text differ
92 EOF
93 test_expect_success 'diff -m respects binary attribute' '
94 git show --format=%s -m >actual &&
95 test_cmp expect actual
98 cat >expect <<EOF
99 resolved
101 diff --combined text
102 index $three,$two..$res
103 Binary files differ
105 test_expect_success 'diff -c respects binary attribute' '
106 git show --format=%s -c >actual &&
107 test_cmp expect actual
110 cat >expect <<EOF
111 resolved
113 diff --cc text
114 index $three,$two..$res
115 Binary files differ
117 test_expect_success 'diff --cc respects binary attribute' '
118 git show --format=%s --cc >actual &&
119 test_cmp expect actual
122 test_expect_success 'setup textconv attribute' '
123 echo "text diff=upcase" >.gitattributes &&
124 git config diff.upcase.textconv "tr a-z A-Z <"
127 cat >expect <<EOF
128 resolved
130 diff --git a/text b/text
131 index $three..$res 100644
132 --- a/text
133 +++ b/text
134 @@ -1 +1 @@
135 -THREE
136 +RESOLVED
137 resolved
139 diff --git a/text b/text
140 index $two..$res 100644
141 --- a/text
142 +++ b/text
143 @@ -1 +1 @@
144 -TWO
145 +RESOLVED
147 test_expect_success 'diff -m respects textconv attribute' '
148 git show --format=%s -m >actual &&
149 test_cmp expect actual
152 cat >expect <<EOF
153 resolved
155 diff --combined text
156 index $three,$two..$res
157 --- a/text
158 +++ b/text
159 @@@ -1,1 -1,1 +1,1 @@@
160 - THREE
161 -TWO
162 ++RESOLVED
164 test_expect_success 'diff -c respects textconv attribute' '
165 git show --format=%s -c >actual &&
166 test_cmp expect actual
169 cat >expect <<EOF
170 resolved
172 diff --cc text
173 index $three,$two..$res
174 --- a/text
175 +++ b/text
176 @@@ -1,1 -1,1 +1,1 @@@
177 - THREE
178 -TWO
179 ++RESOLVED
181 test_expect_success 'diff --cc respects textconv attribute' '
182 git show --format=%s --cc >actual &&
183 test_cmp expect actual
186 cat >expect <<EOF
187 diff --combined text
188 index $three,$two..$res
189 --- a/text
190 +++ b/text
191 @@@ -1,1 -1,1 +1,1 @@@
192 - three
193 -two
194 ++resolved
196 test_expect_success 'diff-tree plumbing does not respect textconv' '
197 git diff-tree HEAD -c -p >full &&
198 tail -n +2 full >actual &&
199 test_cmp expect actual
202 cat >expect <<EOF
203 diff --cc text
204 index $three,$two..0000000
205 --- a/text
206 +++ b/text
207 @@@ -1,1 -1,1 +1,5 @@@
208 ++<<<<<<< HEAD
209 +THREE
210 ++=======
211 + TWO
212 ++>>>>>>> MAIN
214 test_expect_success 'diff --cc respects textconv on worktree file' '
215 git reset --hard HEAD^ &&
216 test_must_fail git merge main &&
217 git diff >actual &&
218 test_cmp expect actual
221 test_done