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