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 ) &&
73 test_path_is_missing a.txt
77 test_expect_success
"merge without conflict (--quiet)" \
78 "git merge-file --quiet test.txt orig.txt new2.txt"
81 test_expect_success
"merge without conflict (missing LF at EOF)" \
82 "git merge-file test2.txt orig.txt new2.txt"
84 test_expect_success
"merge result added missing LF" \
85 "test_cmp test.txt test2.txt"
87 cp test.txt backup.txt
88 test_expect_success
"merge with conflicts" \
89 "test_must_fail git merge-file test.txt orig.txt new3.txt"
91 cat > expect.txt
<< EOF
93 Dominus regit me, et nihil mihi deerit.
98 In loco pascuae ibi me collocavit,
99 super aquam refectionis educavit me;
100 animam meam convertit,
101 deduxit me super semitas jusitiae,
103 Nam et si ambulavero in medio umbrae mortis,
104 non timebo mala, quoniam tu mecum es:
105 virga tua et baculus tuus ipsa me consolata sunt.
108 test_expect_success
"expected conflict markers" "test_cmp test.txt expect.txt"
110 cp backup.txt
test.txt
111 test_expect_success
"merge with conflicts, using -L" \
112 "test_must_fail git merge-file -L 1 -L 2 test.txt orig.txt new3.txt"
114 cat > expect.txt
<< EOF
116 Dominus regit me, et nihil mihi deerit.
119 et nihil mihi deerit.
121 In loco pascuae ibi me collocavit,
122 super aquam refectionis educavit me;
123 animam meam convertit,
124 deduxit me super semitas jusitiae,
126 Nam et si ambulavero in medio umbrae mortis,
127 non timebo mala, quoniam tu mecum es:
128 virga tua et baculus tuus ipsa me consolata sunt.
131 test_expect_success
"expected conflict markers, with -L" \
132 "test_cmp test.txt expect.txt"
134 sed "s/ tu / TU /" < new1.txt
> new5.txt
135 test_expect_success
"conflict in removed tail" \
136 "test_must_fail git merge-file -p orig.txt new1.txt new5.txt > out"
140 et nihil mihi deerit.
141 In loco pascuae ibi me collocavit,
142 super aquam refectionis educavit me;
143 animam meam convertit,
144 deduxit me super semitas jusitiae,
148 Nam et si ambulavero in medio umbrae mortis,
149 non timebo mala, quoniam TU mecum es:
150 virga tua et baculus tuus ipsa me consolata sunt.
154 test_expect_success
"expected conflict markers" "test_cmp expect out"
156 test_expect_success
'binary files cannot be merged' '
157 test_must_fail git merge-file -p \
158 orig.txt "$TEST_DIRECTORY"/test-binary-1.png new1.txt 2> merge.err &&
159 grep "Cannot merge binary files" merge.err
162 sed -e "s/deerit.\$/deerit;/" -e "s/me;\$/me./" < new5.txt
> new6.txt
163 sed -e "s/deerit.\$/deerit,/" -e "s/me;\$/me,/" < new5.txt
> new7.txt
165 test_expect_success
'MERGE_ZEALOUS simplifies non-conflicts' '
167 test_must_fail git merge-file -p new6.txt new5.txt new7.txt > output &&
168 test 1 = $(grep ======= < output | wc -l)
172 sed -e 's/deerit./&%%%%/' -e "s/locavit,/locavit;/"< new6.txt |
tr '%' '\012' > new8.txt
173 sed -e 's/deerit./&%%%%/' -e "s/locavit,/locavit --/" < new7.txt |
tr '%' '\012' > new9.txt
175 test_expect_success
'ZEALOUS_ALNUM' '
177 test_must_fail git merge-file -p \
178 new8.txt new5.txt new9.txt > merge.out &&
179 test 1 = $(grep ======= < merge.out | wc -l)
186 et nihil mihi deerit;
191 In loco pascuae ibi me collocavit;
192 super aquam refectionis educavit me.
194 et nihil mihi deerit.
195 In loco pascuae ibi me collocavit,
196 super aquam refectionis educavit me;
198 et nihil mihi deerit,
203 In loco pascuae ibi me collocavit --
204 super aquam refectionis educavit me,
206 animam meam convertit,
207 deduxit me super semitas jusitiae,
209 Nam et si ambulavero in medio umbrae mortis,
210 non timebo mala, quoniam TU mecum es:
211 virga tua et baculus tuus ipsa me consolata sunt.
214 test_expect_success '"diff3 -m" style output (1)' '
215 test_must_fail git merge-file -p --diff3 \
216 new8.txt new5.txt new9.txt
>actual
&&
217 test_cmp expect actual
220 test_expect_success '"diff3 -m" style output
(2)' '
221 git config merge.conflictstyle
diff3 &&
222 test_must_fail git merge-file
-p \
223 new8.txt new5.txt new9.txt
>actual
&&
224 test_cmp expect actual
230 et nihil mihi deerit;
235 In loco pascuae ibi me collocavit;
236 super aquam refectionis educavit me.
238 et nihil mihi deerit.
239 In loco pascuae ibi me collocavit,
240 super aquam refectionis educavit me;
242 et nihil mihi deerit,
247 In loco pascuae ibi me collocavit --
248 super aquam refectionis educavit me,
250 animam meam convertit,
251 deduxit me super semitas jusitiae,
253 Nam et si ambulavero in medio umbrae mortis,
254 non timebo mala, quoniam TU mecum es:
255 virga tua et baculus tuus ipsa me consolata sunt.
258 test_expect_success 'marker size
' '
259 test_must_fail git merge-file
-p --marker-size=10 \
260 new8.txt new5.txt new9.txt
>actual
&&
261 test_cmp expect actual