]>
Commit | Line | Data |
---|---|---|
4d5f3471 JK |
1 | #!/bin/sh |
2 | ||
3 | test_description='combined and merge diff handle binary files and textconv' | |
8f37854b | 4 | GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main |
334afbc7 JS |
5 | export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME |
6 | ||
4d5f3471 JK |
7 | . ./test-lib.sh |
8 | ||
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 && | |
fa26d5ed | 15 | two=$(git rev-parse --short HEAD:binary) && |
4d5f3471 JK |
16 | git checkout -b branch-binary HEAD^ && |
17 | echo threeQ3 | q_to_nul >binary && | |
18 | git commit -a -m three && | |
fa26d5ed | 19 | three=$(git rev-parse --short HEAD:binary) && |
8f37854b | 20 | test_must_fail git merge main && |
4d5f3471 | 21 | echo resolvedQhooray | q_to_nul >binary && |
fa26d5ed | 22 | git commit -a -m resolved && |
23 | res=$(git rev-parse --short HEAD:binary) | |
4d5f3471 JK |
24 | ' |
25 | ||
fa26d5ed | 26 | cat >expect <<EOF |
4d5f3471 JK |
27 | resolved |
28 | ||
29 | diff --git a/binary b/binary | |
fa26d5ed | 30 | index $three..$res 100644 |
4d5f3471 JK |
31 | Binary files a/binary and b/binary differ |
32 | resolved | |
33 | ||
34 | diff --git a/binary b/binary | |
fa26d5ed | 35 | index $two..$res 100644 |
4d5f3471 JK |
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 | |
41 | ' | |
42 | ||
fa26d5ed | 43 | cat >expect <<EOF |
4d5f3471 JK |
44 | resolved |
45 | ||
46 | diff --combined binary | |
fa26d5ed | 47 | index $three,$two..$res |
4d5f3471 JK |
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 | |
53 | ' | |
54 | ||
fa26d5ed | 55 | cat >expect <<EOF |
4d5f3471 JK |
56 | resolved |
57 | ||
58 | diff --cc binary | |
fa26d5ed | 59 | index $three,$two..$res |
4d5f3471 JK |
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 | |
65 | ' | |
66 | ||
67 | test_expect_success 'setup non-binary with binary attribute' ' | |
8f37854b | 68 | git checkout main && |
4d5f3471 JK |
69 | test_commit one text && |
70 | test_commit two text && | |
fa26d5ed | 71 | two=$(git rev-parse --short HEAD:text) && |
4d5f3471 JK |
72 | git checkout -b branch-text HEAD^ && |
73 | test_commit three text && | |
fa26d5ed | 74 | three=$(git rev-parse --short HEAD:text) && |
8f37854b | 75 | test_must_fail git merge main && |
4d5f3471 | 76 | test_commit resolved text && |
fa26d5ed | 77 | res=$(git rev-parse --short HEAD:text) && |
4d5f3471 JK |
78 | echo text -diff >.gitattributes |
79 | ' | |
80 | ||
fa26d5ed | 81 | cat >expect <<EOF |
4d5f3471 JK |
82 | resolved |
83 | ||
84 | diff --git a/text b/text | |
fa26d5ed | 85 | index $three..$res 100644 |
4d5f3471 JK |
86 | Binary files a/text and b/text differ |
87 | resolved | |
88 | ||
89 | diff --git a/text b/text | |
fa26d5ed | 90 | index $two..$res 100644 |
4d5f3471 JK |
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 | |
96 | ' | |
97 | ||
fa26d5ed | 98 | cat >expect <<EOF |
4d5f3471 JK |
99 | resolved |
100 | ||
101 | diff --combined text | |
fa26d5ed | 102 | index $three,$two..$res |
4d5f3471 JK |
103 | Binary files differ |
104 | EOF | |
105 | test_expect_success 'diff -c respects binary attribute' ' | |
106 | git show --format=%s -c >actual && | |
107 | test_cmp expect actual | |
108 | ' | |
109 | ||
fa26d5ed | 110 | cat >expect <<EOF |
4d5f3471 JK |
111 | resolved |
112 | ||
113 | diff --cc text | |
fa26d5ed | 114 | index $three,$two..$res |
4d5f3471 JK |
115 | Binary files differ |
116 | EOF | |
117 | test_expect_success 'diff --cc respects binary attribute' ' | |
118 | git show --format=%s --cc >actual && | |
119 | test_cmp expect actual | |
120 | ' | |
121 | ||
0508fe53 JK |
122 | test_expect_success 'setup textconv attribute' ' |
123 | echo "text diff=upcase" >.gitattributes && | |
124 | git config diff.upcase.textconv "tr a-z A-Z <" | |
125 | ' | |
126 | ||
fa26d5ed | 127 | cat >expect <<EOF |
0508fe53 JK |
128 | resolved |
129 | ||
130 | diff --git a/text b/text | |
fa26d5ed | 131 | index $three..$res 100644 |
0508fe53 JK |
132 | --- a/text |
133 | +++ b/text | |
134 | @@ -1 +1 @@ | |
135 | -THREE | |
136 | +RESOLVED | |
137 | resolved | |
138 | ||
139 | diff --git a/text b/text | |
fa26d5ed | 140 | index $two..$res 100644 |
0508fe53 JK |
141 | --- a/text |
142 | +++ b/text | |
143 | @@ -1 +1 @@ | |
144 | -TWO | |
145 | +RESOLVED | |
146 | EOF | |
147 | test_expect_success 'diff -m respects textconv attribute' ' | |
148 | git show --format=%s -m >actual && | |
149 | test_cmp expect actual | |
150 | ' | |
151 | ||
fa26d5ed | 152 | cat >expect <<EOF |
0508fe53 JK |
153 | resolved |
154 | ||
155 | diff --combined text | |
fa26d5ed | 156 | index $three,$two..$res |
0508fe53 JK |
157 | --- a/text |
158 | +++ b/text | |
159 | @@@ -1,1 -1,1 +1,1 @@@ | |
160 | - THREE | |
161 | -TWO | |
162 | ++RESOLVED | |
163 | EOF | |
164 | test_expect_success 'diff -c respects textconv attribute' ' | |
165 | git show --format=%s -c >actual && | |
166 | test_cmp expect actual | |
167 | ' | |
168 | ||
fa26d5ed | 169 | cat >expect <<EOF |
0508fe53 JK |
170 | resolved |
171 | ||
172 | diff --cc text | |
fa26d5ed | 173 | index $three,$two..$res |
0508fe53 JK |
174 | --- a/text |
175 | +++ b/text | |
176 | @@@ -1,1 -1,1 +1,1 @@@ | |
177 | - THREE | |
178 | -TWO | |
179 | ++RESOLVED | |
180 | EOF | |
181 | test_expect_success 'diff --cc respects textconv attribute' ' | |
182 | git show --format=%s --cc >actual && | |
183 | test_cmp expect actual | |
184 | ' | |
185 | ||
fa26d5ed | 186 | cat >expect <<EOF |
0508fe53 | 187 | diff --combined text |
fa26d5ed | 188 | index $three,$two..$res |
0508fe53 JK |
189 | --- a/text |
190 | +++ b/text | |
191 | @@@ -1,1 -1,1 +1,1 @@@ | |
192 | - three | |
193 | -two | |
194 | ++resolved | |
195 | EOF | |
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 | |
200 | ' | |
201 | ||
fa26d5ed | 202 | cat >expect <<EOF |
0508fe53 | 203 | diff --cc text |
fa26d5ed | 204 | index $three,$two..0000000 |
0508fe53 JK |
205 | --- a/text |
206 | +++ b/text | |
207 | @@@ -1,1 -1,1 +1,5 @@@ | |
208 | ++<<<<<<< HEAD | |
209 | +THREE | |
210 | ++======= | |
211 | + TWO | |
8f37854b | 212 | ++>>>>>>> MAIN |
0508fe53 JK |
213 | EOF |
214 | test_expect_success 'diff --cc respects textconv on worktree file' ' | |
215 | git reset --hard HEAD^ && | |
8f37854b | 216 | test_must_fail git merge main && |
0508fe53 JK |
217 | git diff >actual && |
218 | test_cmp expect actual | |
219 | ' | |
220 | ||
4d5f3471 | 221 | test_done |