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
9 test_expect_success
'setup binary merge conflict' '
10 echo oneQ1 | q_to_nul >binary &&
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)
29 diff --git a/binary b/binary
30 index $three..$res 100644
31 Binary files a/binary and b/binary differ
34 diff --git a/binary b/binary
35 index $two..$res 100644
36 Binary files a/binary and b/binary differ
38 test_expect_success
'diff -m indicates binary-ness' '
39 git show --format=%s -m >actual &&
40 test_cmp expect actual
46 diff --combined binary
47 index $three,$two..$res
50 test_expect_success
'diff -c indicates binary-ness' '
51 git show --format=%s -c >actual &&
52 test_cmp expect actual
59 index $three,$two..$res
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' '
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
84 diff --git a/text b/text
85 index $three..$res 100644
86 Binary files a/text and b/text differ
89 diff --git a/text b/text
90 index $two..$res 100644
91 Binary files a/text and b/text differ
93 test_expect_success
'diff -m respects binary attribute' '
94 git show --format=%s -m >actual &&
95 test_cmp expect actual
102 index $three,$two..$res
105 test_expect_success
'diff -c respects binary attribute' '
106 git show --format=%s -c >actual &&
107 test_cmp expect actual
114 index $three,$two..$res
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 <"
130 diff --git a/text b/text
131 index $three..$res 100644
139 diff --git a/text b/text
140 index $two..$res 100644
147 test_expect_success
'diff -m respects textconv attribute' '
148 git show --format=%s -m >actual &&
149 test_cmp expect actual
156 index $three,$two..$res
159 @@@ -1,1 -1,1 +1,1 @@@
164 test_expect_success
'diff -c respects textconv attribute' '
165 git show --format=%s -c >actual &&
166 test_cmp expect actual
173 index $three,$two..$res
176 @@@ -1,1 -1,1 +1,1 @@@
181 test_expect_success
'diff --cc respects textconv attribute' '
182 git show --format=%s --cc >actual &&
183 test_cmp expect actual
188 index $three,$two..$res
191 @@@ -1,1 -1,1 +1,1 @@@
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
204 index $three,$two..0000000
207 @@@ -1,1 -1,1 +1,5 @@@
214 test_expect_success
'diff --cc respects textconv on worktree file' '
215 git reset --hard HEAD^ &&
216 test_must_fail git merge main &&
218 test_cmp expect actual