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"
68 test_expect_success "merge without conflict (missing LF at EOF)" \
69 "git merge-file test2.txt orig.txt new2.txt"
71 test_expect_success "merge result added missing LF" \
72 "test_cmp test.txt test2.txt"
74 cp test.txt backup.txt
75 test_expect_success "merge with conflicts" \
76 "test_must_fail git merge-file test.txt orig.txt new3.txt"
78 cat > expect.txt << EOF
80 Dominus regit me, et nihil mihi deerit.
85 In loco pascuae ibi me collocavit,
86 super aquam refectionis educavit me;
87 animam meam convertit,
88 deduxit me super semitas jusitiae,
90 Nam et si ambulavero in medio umbrae mortis,
91 non timebo mala, quoniam tu mecum es:
92 virga tua et baculus tuus ipsa me consolata sunt.
95 test_expect_success "expected conflict markers" "test_cmp test.txt expect.txt"
97 cp backup.txt test.txt
98 test_expect_success "merge with conflicts, using -L" \
99 "test_must_fail git merge-file -L 1 -L 2 test.txt orig.txt new3.txt"
101 cat > expect.txt << EOF
103 Dominus regit me, et nihil mihi deerit.
106 et nihil mihi deerit.
108 In loco pascuae ibi me collocavit,
109 super aquam refectionis educavit me;
110 animam meam convertit,
111 deduxit me super semitas jusitiae,
113 Nam et si ambulavero in medio umbrae mortis,
114 non timebo mala, quoniam tu mecum es:
115 virga tua et baculus tuus ipsa me consolata sunt.
118 test_expect_success "expected conflict markers, with -L" \
119 "test_cmp test.txt expect.txt"
121 sed "s/ tu / TU /" < new1.txt > new5.txt
122 test_expect_success "conflict in removed tail" \
123 "test_must_fail git merge-file -p orig.txt new1.txt new5.txt > out"
127 et nihil mihi deerit.
128 In loco pascuae ibi me collocavit,
129 super aquam refectionis educavit me;
130 animam meam convertit,
131 deduxit me super semitas jusitiae,
135 Nam et si ambulavero in medio umbrae mortis,
136 non timebo mala, quoniam TU mecum es:
137 virga tua et baculus tuus ipsa me consolata sunt.
141 test_expect_success "expected conflict markers" "test_cmp expect out"
143 test_expect_success 'binary files cannot be merged' '
144 test_must_fail git merge-file -p \
145 orig.txt "$TEST_DIRECTORY"/test4012.png new1.txt 2> merge.err &&
146 grep "Cannot merge binary files" merge.err
149 sed -e "s/deerit.\$/deerit;/" -e "s/me;\$/me./" < new5.txt > new6.txt
150 sed -e "s/deerit.\$/deerit,/" -e "s/me;\$/me,/" < new5.txt > new7.txt
152 test_expect_success 'MERGE_ZEALOUS simplifies non-conflicts' '
154 test_must_fail git merge-file -p new6.txt new5.txt new7.txt > output &&
155 test 1 = $(grep ======= < output | wc -l)
159 sed -e 's/deerit./&%%%%/' -e "s/locavit,/locavit;/"< new6.txt | tr '%' '\012' > new8.txt
160 sed -e 's/deerit./&%%%%/' -e "s/locavit,/locavit --/" < new7.txt | tr '%' '\012' > new9.txt
162 test_expect_success 'ZEALOUS_ALNUM' '
164 test_must_fail git merge-file -p \
165 new8.txt new5.txt new9.txt > merge.out &&
166 test 1 = $(grep ======= < merge.out | wc -l)
173 et nihil mihi deerit;
178 In loco pascuae ibi me collocavit;
179 super aquam refectionis educavit me.
181 et nihil mihi deerit.
182 In loco pascuae ibi me collocavit,
183 super aquam refectionis educavit me;
185 et nihil mihi deerit,
190 In loco pascuae ibi me collocavit --
191 super aquam refectionis educavit me,
193 animam meam convertit,
194 deduxit me super semitas jusitiae,
196 Nam et si ambulavero in medio umbrae mortis,
197 non timebo mala, quoniam TU mecum es:
198 virga tua et baculus tuus ipsa me consolata sunt.
201 test_expect_success '"diff3 -m" style output (1)' '
202 test_must_fail git merge-file -p --diff3 \
203 new8.txt new5.txt new9.txt >actual &&
204 test_cmp expect actual
207 test_expect_success '"diff3 -m" style output (2)' '
208 git config merge.conflictstyle diff3 &&
209 test_must_fail git merge-file -p \
210 new8.txt new5.txt new9.txt >actual &&
211 test_cmp expect actual