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_PASSES_SANITIZE_LEAK
=true
10 test_expect_success
'setup binary merge conflict' '
11 echo oneQ1 | q_to_nul >binary &&
14 echo twoQ2 | q_to_nul >binary &&
15 git commit -a -m two &&
16 two=$(git rev-parse --short HEAD:binary) &&
17 git checkout -b branch-binary HEAD^ &&
18 echo threeQ3 | q_to_nul >binary &&
19 git commit -a -m three &&
20 three=$(git rev-parse --short HEAD:binary) &&
21 test_must_fail git merge main &&
22 echo resolvedQhooray | q_to_nul >binary &&
23 git commit -a -m resolved &&
24 res=$(git rev-parse --short HEAD:binary)
30 diff --git a/binary b/binary
31 index $three..$res 100644
32 Binary files a/binary and b/binary differ
35 diff --git a/binary b/binary
36 index $two..$res 100644
37 Binary files a/binary and b/binary differ
39 test_expect_success
'diff -m indicates binary-ness' '
40 git show --format=%s -m >actual &&
41 test_cmp expect actual
47 diff --combined binary
48 index $three,$two..$res
51 test_expect_success
'diff -c indicates binary-ness' '
52 git show --format=%s -c >actual &&
53 test_cmp expect actual
60 index $three,$two..$res
63 test_expect_success
'diff --cc indicates binary-ness' '
64 git show --format=%s --cc >actual &&
65 test_cmp expect actual
68 test_expect_success
'setup non-binary with binary attribute' '
70 test_commit one text &&
71 test_commit two text &&
72 two=$(git rev-parse --short HEAD:text) &&
73 git checkout -b branch-text HEAD^ &&
74 test_commit three text &&
75 three=$(git rev-parse --short HEAD:text) &&
76 test_must_fail git merge main &&
77 test_commit resolved text &&
78 res=$(git rev-parse --short HEAD:text) &&
79 echo text -diff >.gitattributes
85 diff --git a/text b/text
86 index $three..$res 100644
87 Binary files a/text and b/text differ
90 diff --git a/text b/text
91 index $two..$res 100644
92 Binary files a/text and b/text differ
94 test_expect_success
'diff -m respects binary attribute' '
95 git show --format=%s -m >actual &&
96 test_cmp expect actual
103 index $three,$two..$res
106 test_expect_success
'diff -c respects binary attribute' '
107 git show --format=%s -c >actual &&
108 test_cmp expect actual
115 index $three,$two..$res
118 test_expect_success
'diff --cc respects binary attribute' '
119 git show --format=%s --cc >actual &&
120 test_cmp expect actual
123 test_expect_success
'setup textconv attribute' '
124 echo "text diff=upcase" >.gitattributes &&
125 git config diff.upcase.textconv "tr a-z A-Z <"
131 diff --git a/text b/text
132 index $three..$res 100644
140 diff --git a/text b/text
141 index $two..$res 100644
148 test_expect_success
'diff -m respects textconv attribute' '
149 git show --format=%s -m >actual &&
150 test_cmp expect actual
157 index $three,$two..$res
160 @@@ -1,1 -1,1 +1,1 @@@
165 test_expect_success
'diff -c respects textconv attribute' '
166 git show --format=%s -c >actual &&
167 test_cmp expect actual
174 index $three,$two..$res
177 @@@ -1,1 -1,1 +1,1 @@@
182 test_expect_success
'diff --cc respects textconv attribute' '
183 git show --format=%s --cc >actual &&
184 test_cmp expect actual
189 index $three,$two..$res
192 @@@ -1,1 -1,1 +1,1 @@@
197 test_expect_success
'diff-tree plumbing does not respect textconv' '
198 git diff-tree HEAD -c -p >full &&
199 tail -n +2 full >actual &&
200 test_cmp expect actual
205 index $three,$two..0000000
208 @@@ -1,1 -1,1 +1,5 @@@
215 test_expect_success
'diff --cc respects textconv on worktree file' '
216 git reset --hard HEAD^ &&
217 test_must_fail git merge main &&
219 test_cmp expect actual