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 (--quiet)" \
69 "git merge-file --quiet test.txt orig.txt new2.txt"
72 test_expect_success "merge without conflict (missing LF at EOF)" \
73 "git merge-file test2.txt orig.txt new2.txt"
75 test_expect_success "merge result added missing LF" \
76 "test_cmp test.txt test2.txt"
78 cp test.txt backup.txt
79 test_expect_success "merge with conflicts" \
80 "test_must_fail git merge-file test.txt orig.txt new3.txt"
82 cat > expect.txt << EOF
84 Dominus regit me, et nihil mihi deerit.
89 In loco pascuae ibi me collocavit,
90 super aquam refectionis educavit me;
91 animam meam convertit,
92 deduxit me super semitas jusitiae,
94 Nam et si ambulavero in medio umbrae mortis,
95 non timebo mala, quoniam tu mecum es:
96 virga tua et baculus tuus ipsa me consolata sunt.
99 test_expect_success "expected conflict markers" "test_cmp test.txt expect.txt"
101 cp backup.txt test.txt
102 test_expect_success "merge with conflicts, using -L" \
103 "test_must_fail git merge-file -L 1 -L 2 test.txt orig.txt new3.txt"
105 cat > expect.txt << EOF
107 Dominus regit me, et nihil mihi deerit.
110 et nihil mihi deerit.
112 In loco pascuae ibi me collocavit,
113 super aquam refectionis educavit me;
114 animam meam convertit,
115 deduxit me super semitas jusitiae,
117 Nam et si ambulavero in medio umbrae mortis,
118 non timebo mala, quoniam tu mecum es:
119 virga tua et baculus tuus ipsa me consolata sunt.
122 test_expect_success "expected conflict markers, with -L" \
123 "test_cmp test.txt expect.txt"
125 sed "s/ tu / TU /" < new1.txt > new5.txt
126 test_expect_success "conflict in removed tail" \
127 "test_must_fail git merge-file -p orig.txt new1.txt new5.txt > out"
131 et nihil mihi deerit.
132 In loco pascuae ibi me collocavit,
133 super aquam refectionis educavit me;
134 animam meam convertit,
135 deduxit me super semitas jusitiae,
139 Nam et si ambulavero in medio umbrae mortis,
140 non timebo mala, quoniam TU mecum es:
141 virga tua et baculus tuus ipsa me consolata sunt.
145 test_expect_success "expected conflict markers" "test_cmp expect out"
147 test_expect_success 'binary files cannot be merged' '
148 test_must_fail git merge-file -p \
149 orig.txt "$TEST_DIRECTORY"/test4012.png new1.txt 2> merge.err &&
150 grep "Cannot merge binary files" merge.err
153 sed -e "s/deerit.\$/deerit;/" -e "s/me;\$/me./" < new5.txt > new6.txt
154 sed -e "s/deerit.\$/deerit,/" -e "s/me;\$/me,/" < new5.txt > new7.txt
156 test_expect_success 'MERGE_ZEALOUS simplifies non-conflicts' '
158 test_must_fail git merge-file -p new6.txt new5.txt new7.txt > output &&
159 test 1 = $(grep ======= < output | wc -l)
163 sed -e 's/deerit./&%%%%/' -e "s/locavit,/locavit;/"< new6.txt | tr '%' '\012' > new8.txt
164 sed -e 's/deerit./&%%%%/' -e "s/locavit,/locavit --/" < new7.txt | tr '%' '\012' > new9.txt
166 test_expect_success 'ZEALOUS_ALNUM' '
168 test_must_fail git merge-file -p \
169 new8.txt new5.txt new9.txt > merge.out &&
170 test 1 = $(grep ======= < merge.out | wc -l)
177 et nihil mihi deerit;
182 In loco pascuae ibi me collocavit;
183 super aquam refectionis educavit me.
185 et nihil mihi deerit.
186 In loco pascuae ibi me collocavit,
187 super aquam refectionis educavit me;
189 et nihil mihi deerit,
194 In loco pascuae ibi me collocavit --
195 super aquam refectionis educavit me,
197 animam meam convertit,
198 deduxit me super semitas jusitiae,
200 Nam et si ambulavero in medio umbrae mortis,
201 non timebo mala, quoniam TU mecum es:
202 virga tua et baculus tuus ipsa me consolata sunt.
205 test_expect_success '"diff3 -m" style output (1)' '
206 test_must_fail git merge-file -p --diff3 \
207 new8.txt new5.txt new9.txt >actual &&
208 test_cmp expect actual
211 test_expect_success '"diff3 -m" style output (2)' '
212 git config merge.conflictstyle diff3 &&
213 test_must_fail git merge-file -p \
214 new8.txt new5.txt new9.txt >actual &&
215 test_cmp expect actual