]> git.ipfire.org Git - thirdparty/git.git/blame - t/t4048-diff-combined-binary.sh
The sixth batch
[thirdparty/git.git] / t / t4048-diff-combined-binary.sh
CommitLineData
4d5f3471
JK
1#!/bin/sh
2
3test_description='combined and merge diff handle binary files and textconv'
4. ./test-lib.sh
5
6test_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 23cat >expect <<EOF
4d5f3471
JK
24resolved
25
26diff --git a/binary b/binary
fa26d5ed 27index $three..$res 100644
4d5f3471
JK
28Binary files a/binary and b/binary differ
29resolved
30
31diff --git a/binary b/binary
fa26d5ed 32index $two..$res 100644
4d5f3471
JK
33Binary files a/binary and b/binary differ
34EOF
35test_expect_success 'diff -m indicates binary-ness' '
36 git show --format=%s -m >actual &&
37 test_cmp expect actual
38'
39
fa26d5ed 40cat >expect <<EOF
4d5f3471
JK
41resolved
42
43diff --combined binary
fa26d5ed 44index $three,$two..$res
4d5f3471
JK
45Binary files differ
46EOF
47test_expect_success 'diff -c indicates binary-ness' '
48 git show --format=%s -c >actual &&
49 test_cmp expect actual
50'
51
fa26d5ed 52cat >expect <<EOF
4d5f3471
JK
53resolved
54
55diff --cc binary
fa26d5ed 56index $three,$two..$res
4d5f3471
JK
57Binary files differ
58EOF
59test_expect_success 'diff --cc indicates binary-ness' '
60 git show --format=%s --cc >actual &&
61 test_cmp expect actual
62'
63
64test_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 78cat >expect <<EOF
4d5f3471
JK
79resolved
80
81diff --git a/text b/text
fa26d5ed 82index $three..$res 100644
4d5f3471
JK
83Binary files a/text and b/text differ
84resolved
85
86diff --git a/text b/text
fa26d5ed 87index $two..$res 100644
4d5f3471
JK
88Binary files a/text and b/text differ
89EOF
90test_expect_success 'diff -m respects binary attribute' '
91 git show --format=%s -m >actual &&
92 test_cmp expect actual
93'
94
fa26d5ed 95cat >expect <<EOF
4d5f3471
JK
96resolved
97
98diff --combined text
fa26d5ed 99index $three,$two..$res
4d5f3471
JK
100Binary files differ
101EOF
102test_expect_success 'diff -c respects binary attribute' '
103 git show --format=%s -c >actual &&
104 test_cmp expect actual
105'
106
fa26d5ed 107cat >expect <<EOF
4d5f3471
JK
108resolved
109
110diff --cc text
fa26d5ed 111index $three,$two..$res
4d5f3471
JK
112Binary files differ
113EOF
114test_expect_success 'diff --cc respects binary attribute' '
115 git show --format=%s --cc >actual &&
116 test_cmp expect actual
117'
118
0508fe53
JK
119test_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 124cat >expect <<EOF
0508fe53
JK
125resolved
126
127diff --git a/text b/text
fa26d5ed 128index $three..$res 100644
0508fe53
JK
129--- a/text
130+++ b/text
131@@ -1 +1 @@
132-THREE
133+RESOLVED
134resolved
135
136diff --git a/text b/text
fa26d5ed 137index $two..$res 100644
0508fe53
JK
138--- a/text
139+++ b/text
140@@ -1 +1 @@
141-TWO
142+RESOLVED
143EOF
144test_expect_success 'diff -m respects textconv attribute' '
145 git show --format=%s -m >actual &&
146 test_cmp expect actual
147'
148
fa26d5ed 149cat >expect <<EOF
0508fe53
JK
150resolved
151
152diff --combined text
fa26d5ed 153index $three,$two..$res
0508fe53
JK
154--- a/text
155+++ b/text
156@@@ -1,1 -1,1 +1,1 @@@
157- THREE
158 -TWO
159++RESOLVED
160EOF
161test_expect_success 'diff -c respects textconv attribute' '
162 git show --format=%s -c >actual &&
163 test_cmp expect actual
164'
165
fa26d5ed 166cat >expect <<EOF
0508fe53
JK
167resolved
168
169diff --cc text
fa26d5ed 170index $three,$two..$res
0508fe53
JK
171--- a/text
172+++ b/text
173@@@ -1,1 -1,1 +1,1 @@@
174- THREE
175 -TWO
176++RESOLVED
177EOF
178test_expect_success 'diff --cc respects textconv attribute' '
179 git show --format=%s --cc >actual &&
180 test_cmp expect actual
181'
182
fa26d5ed 183cat >expect <<EOF
0508fe53 184diff --combined text
fa26d5ed 185index $three,$two..$res
0508fe53
JK
186--- a/text
187+++ b/text
188@@@ -1,1 -1,1 +1,1 @@@
189- three
190 -two
191++resolved
192EOF
193test_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 199cat >expect <<EOF
0508fe53 200diff --cc text
fa26d5ed 201index $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
210EOF
211test_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 218test_done