3 test_description
='RCS merge replacement: merge-file'
9 In loco pascuae ibi me collocavit,
10 super aquam refectionis educavit me;
11 animam meam convertit,
12 deduxit me super semitas jusitiae,
19 In loco pascuae ibi me collocavit,
20 super aquam refectionis educavit me;
21 animam meam convertit,
22 deduxit me super semitas jusitiae,
24 Nam et si ambulavero in medio umbrae mortis,
25 non timebo mala, quoniam tu mecum es:
26 virga tua et baculus tuus ipsa me consolata sunt.
30 Dominus regit me, et nihil mihi deerit.
31 In loco pascuae ibi me collocavit,
32 super aquam refectionis educavit me;
33 animam meam convertit,
34 deduxit me super semitas jusitiae,
41 In loco pascuae ibi me collocavit,
42 super aquam refectionis educavit me;
43 animam meam convertit,
44 deduxit me super semitas jusitiae,
49 Dominus regit me, et nihil mihi deerit.
50 In loco pascuae ibi me collocavit,
51 super aquam refectionis educavit me;
52 animam meam convertit,
53 deduxit me super semitas jusitiae,
55 printf "propter nomen suum." >> new4.txt
57 test_expect_success
'merge with no changes' '
58 cp orig.txt test.txt &&
59 git merge-file test.txt orig.txt orig.txt &&
60 test_cmp test.txt orig.txt
64 test_expect_success
"merge without conflict" \
65 "git merge-file test.txt orig.txt new2.txt"
67 test_expect_success
'works in subdirectory' '
69 cp new1.txt dir/a.txt &&
70 cp orig.txt dir/o.txt &&
71 cp new2.txt dir/b.txt &&
72 ( cd dir && git merge-file a.txt o.txt b.txt )
76 test_expect_success
"merge without conflict (--quiet)" \
77 "git merge-file --quiet test.txt orig.txt new2.txt"
80 test_expect_success
"merge without conflict (missing LF at EOF)" \
81 "git merge-file test2.txt orig.txt new2.txt"
83 test_expect_success
"merge result added missing LF" \
84 "test_cmp test.txt test2.txt"
86 cp test.txt backup.txt
87 test_expect_success
"merge with conflicts" \
88 "test_must_fail git merge-file test.txt orig.txt new3.txt"
90 cat > expect.txt
<< EOF
92 Dominus regit me, et nihil mihi deerit.
97 In loco pascuae ibi me collocavit,
98 super aquam refectionis educavit me;
99 animam meam convertit,
100 deduxit me super semitas jusitiae,
102 Nam et si ambulavero in medio umbrae mortis,
103 non timebo mala, quoniam tu mecum es:
104 virga tua et baculus tuus ipsa me consolata sunt.
107 test_expect_success
"expected conflict markers" "test_cmp test.txt expect.txt"
109 cp backup.txt
test.txt
110 test_expect_success
"merge with conflicts, using -L" \
111 "test_must_fail git merge-file -L 1 -L 2 test.txt orig.txt new3.txt"
113 cat > expect.txt
<< EOF
115 Dominus regit me, et nihil mihi deerit.
118 et nihil mihi deerit.
120 In loco pascuae ibi me collocavit,
121 super aquam refectionis educavit me;
122 animam meam convertit,
123 deduxit me super semitas jusitiae,
125 Nam et si ambulavero in medio umbrae mortis,
126 non timebo mala, quoniam tu mecum es:
127 virga tua et baculus tuus ipsa me consolata sunt.
130 test_expect_success
"expected conflict markers, with -L" \
131 "test_cmp test.txt expect.txt"
133 sed "s/ tu / TU /" < new1.txt
> new5.txt
134 test_expect_success
"conflict in removed tail" \
135 "test_must_fail git merge-file -p orig.txt new1.txt new5.txt > out"
139 et nihil mihi deerit.
140 In loco pascuae ibi me collocavit,
141 super aquam refectionis educavit me;
142 animam meam convertit,
143 deduxit me super semitas jusitiae,
147 Nam et si ambulavero in medio umbrae mortis,
148 non timebo mala, quoniam TU mecum es:
149 virga tua et baculus tuus ipsa me consolata sunt.
153 test_expect_success
"expected conflict markers" "test_cmp expect out"
155 test_expect_success
'binary files cannot be merged' '
156 test_must_fail git merge-file -p \
157 orig.txt "$TEST_DIRECTORY"/test-binary-1.png new1.txt 2> merge.err &&
158 grep "Cannot merge binary files" merge.err
161 sed -e "s/deerit.\$/deerit;/" -e "s/me;\$/me./" < new5.txt
> new6.txt
162 sed -e "s/deerit.\$/deerit,/" -e "s/me;\$/me,/" < new5.txt
> new7.txt
164 test_expect_success
'MERGE_ZEALOUS simplifies non-conflicts' '
166 test_must_fail git merge-file -p new6.txt new5.txt new7.txt > output &&
167 test 1 = $(grep ======= < output | wc -l)
171 sed -e 's/deerit./&%%%%/' -e "s/locavit,/locavit;/"< new6.txt |
tr '%' '\012' > new8.txt
172 sed -e 's/deerit./&%%%%/' -e "s/locavit,/locavit --/" < new7.txt |
tr '%' '\012' > new9.txt
174 test_expect_success
'ZEALOUS_ALNUM' '
176 test_must_fail git merge-file -p \
177 new8.txt new5.txt new9.txt > merge.out &&
178 test 1 = $(grep ======= < merge.out | wc -l)
185 et nihil mihi deerit;
190 In loco pascuae ibi me collocavit;
191 super aquam refectionis educavit me.
193 et nihil mihi deerit.
194 In loco pascuae ibi me collocavit,
195 super aquam refectionis educavit me;
197 et nihil mihi deerit,
202 In loco pascuae ibi me collocavit --
203 super aquam refectionis educavit me,
205 animam meam convertit,
206 deduxit me super semitas jusitiae,
208 Nam et si ambulavero in medio umbrae mortis,
209 non timebo mala, quoniam TU mecum es:
210 virga tua et baculus tuus ipsa me consolata sunt.
213 test_expect_success '"diff3 -m" style output (1)' '
214 test_must_fail git merge-file -p --diff3 \
215 new8.txt new5.txt new9.txt
>actual
&&
216 test_cmp expect actual
219 test_expect_success '"diff3 -m" style output
(2)' '
220 git config merge.conflictstyle
diff3 &&
221 test_must_fail git merge-file
-p \
222 new8.txt new5.txt new9.txt
>actual
&&
223 test_cmp expect actual
229 et nihil mihi deerit;
234 In loco pascuae ibi me collocavit;
235 super aquam refectionis educavit me.
237 et nihil mihi deerit.
238 In loco pascuae ibi me collocavit,
239 super aquam refectionis educavit me;
241 et nihil mihi deerit,
246 In loco pascuae ibi me collocavit --
247 super aquam refectionis educavit me,
249 animam meam convertit,
250 deduxit me super semitas jusitiae,
252 Nam et si ambulavero in medio umbrae mortis,
253 non timebo mala, quoniam TU mecum es:
254 virga tua et baculus tuus ipsa me consolata sunt.
257 test_expect_success 'marker size
' '
258 test_must_fail git merge-file
-p --marker-size=10 \
259 new8.txt new5.txt new9.txt
>actual
&&
260 test_cmp expect actual