i18n: for-each-ref: mark parseopt strings for translation
[git/jnareb-git.git] / t / t6023-merge-file.sh
blob432f086c063198e82ad8a2f7c8dd175a8685fdf5
1 #!/bin/sh
3 test_description='RCS merge replacement: merge-file'
4 . ./test-lib.sh
6 cat > orig.txt << EOF
7 Dominus regit me,
8 et nihil mihi deerit.
9 In loco pascuae ibi me collocavit,
10 super aquam refectionis educavit me;
11 animam meam convertit,
12 deduxit me super semitas jusitiae,
13 propter nomen suum.
14 EOF
16 cat > new1.txt << EOF
17 Dominus regit me,
18 et nihil mihi deerit.
19 In loco pascuae ibi me collocavit,
20 super aquam refectionis educavit me;
21 animam meam convertit,
22 deduxit me super semitas jusitiae,
23 propter nomen suum.
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.
27 EOF
29 cat > new2.txt << EOF
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,
35 propter nomen suum.
36 EOF
38 cat > new3.txt << EOF
39 DOMINUS regit me,
40 et nihil mihi deerit.
41 In loco pascuae ibi me collocavit,
42 super aquam refectionis educavit me;
43 animam meam convertit,
44 deduxit me super semitas jusitiae,
45 propter nomen suum.
46 EOF
48 cat > new4.txt << EOF
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,
54 EOF
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
63 cp new1.txt test.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' '
68 mkdir dir &&
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 )
75 cp new1.txt test.txt
76 test_expect_success "merge without conflict (--quiet)" \
77 "git merge-file --quiet test.txt orig.txt new2.txt"
79 cp new1.txt test2.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
91 <<<<<<< test.txt
92 Dominus regit me, et nihil mihi deerit.
93 =======
94 DOMINUS regit me,
95 et nihil mihi deerit.
96 >>>>>>> new3.txt
97 In loco pascuae ibi me collocavit,
98 super aquam refectionis educavit me;
99 animam meam convertit,
100 deduxit me super semitas jusitiae,
101 propter nomen suum.
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
114 <<<<<<< 1
115 Dominus regit me, et nihil mihi deerit.
116 =======
117 DOMINUS regit me,
118 et nihil mihi deerit.
119 >>>>>>> new3.txt
120 In loco pascuae ibi me collocavit,
121 super aquam refectionis educavit me;
122 animam meam convertit,
123 deduxit me super semitas jusitiae,
124 propter nomen suum.
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"
137 cat > expect << EOF
138 Dominus regit me,
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,
144 propter nomen suum.
145 <<<<<<< orig.txt
146 =======
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.
150 >>>>>>> new5.txt
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)
182 cat >expect <<\EOF
183 Dominus regit me,
184 <<<<<<< new8.txt
185 et nihil mihi deerit;
190 In loco pascuae ibi me collocavit;
191 super aquam refectionis educavit me.
192 ||||||| new5.txt
193 et nihil mihi deerit.
194 In loco pascuae ibi me collocavit,
195 super aquam refectionis educavit me;
196 =======
197 et nihil mihi deerit,
202 In loco pascuae ibi me collocavit --
203 super aquam refectionis educavit me,
204 >>>>>>> new9.txt
205 animam meam convertit,
206 deduxit me super semitas jusitiae,
207 propter nomen suum.
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
226 cat >expect <<\EOF
227 Dominus regit me,
228 <<<<<<<<<< new8.txt
229 et nihil mihi deerit;
234 In loco pascuae ibi me collocavit;
235 super aquam refectionis educavit me.
236 |||||||||| new5.txt
237 et nihil mihi deerit.
238 In loco pascuae ibi me collocavit,
239 super aquam refectionis educavit me;
240 ==========
241 et nihil mihi deerit,
246 In loco pascuae ibi me collocavit --
247 super aquam refectionis educavit me,
248 >>>>>>>>>> new9.txt
249 animam meam convertit,
250 deduxit me super semitas jusitiae,
251 propter nomen suum.
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
263 test_done