@@ -77,12 +77,29 @@ test_expect_success "merge without conflict (--quiet)" \
77
77
" git merge-file --quiet test.txt orig.txt new2.txt"
78
78
79
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"
80
+ test_expect_failure " merge without conflict (missing LF at EOF)" \
81
+ " git merge-file test2.txt orig.txt new4 .txt"
82
82
83
- test_expect_success " merge result added missing LF" \
83
+ test_expect_failure " merge result added missing LF" \
84
84
" test_cmp test.txt test2.txt"
85
85
86
+ cp new4.txt test3.txt
87
+ test_expect_success " merge without conflict (missing LF at EOF, away from change in the other file)" \
88
+ " git merge-file --quiet test3.txt new2.txt new3.txt"
89
+
90
+ cat > expect.txt << EOF
91
+ DOMINUS regit me,
92
+ et nihil mihi deerit.
93
+ In loco pascuae ibi me collocavit,
94
+ super aquam refectionis educavit me;
95
+ animam meam convertit,
96
+ deduxit me super semitas jusitiae,
97
+ EOF
98
+ printf " propter nomen suum." >> expect.txt
99
+
100
+ test_expect_success " merge does not add LF away of change" \
101
+ " test_cmp test3.txt expect.txt"
102
+
86
103
cp test.txt backup.txt
87
104
test_expect_success " merge with conflicts" \
88
105
" test_must_fail git merge-file test.txt orig.txt new3.txt"
107
124
test_expect_success " expected conflict markers" " test_cmp test.txt expect.txt"
108
125
109
126
cp backup.txt test.txt
127
+
128
+ cat > expect.txt << EOF
129
+ Dominus regit me, et nihil mihi deerit.
130
+ In loco pascuae ibi me collocavit,
131
+ super aquam refectionis educavit me;
132
+ animam meam convertit,
133
+ deduxit me super semitas jusitiae,
134
+ propter nomen suum.
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.
138
+ EOF
139
+ test_expect_success " merge conflicting with --ours" \
140
+ " git merge-file --ours test.txt orig.txt new3.txt && test_cmp test.txt expect.txt"
141
+ cp backup.txt test.txt
142
+
143
+ cat > expect.txt << EOF
144
+ DOMINUS regit me,
145
+ et nihil mihi deerit.
146
+ In loco pascuae ibi me collocavit,
147
+ super aquam refectionis educavit me;
148
+ animam meam convertit,
149
+ deduxit me super semitas jusitiae,
150
+ propter nomen suum.
151
+ Nam et si ambulavero in medio umbrae mortis,
152
+ non timebo mala, quoniam tu mecum es:
153
+ virga tua et baculus tuus ipsa me consolata sunt.
154
+ EOF
155
+ test_expect_success " merge conflicting with --theirs" \
156
+ " git merge-file --theirs test.txt orig.txt new3.txt && test_cmp test.txt expect.txt"
157
+ cp backup.txt test.txt
158
+
159
+ cat > expect.txt << EOF
160
+ Dominus regit me, et nihil mihi deerit.
161
+ DOMINUS regit me,
162
+ et nihil mihi deerit.
163
+ In loco pascuae ibi me collocavit,
164
+ super aquam refectionis educavit me;
165
+ animam meam convertit,
166
+ deduxit me super semitas jusitiae,
167
+ propter nomen suum.
168
+ Nam et si ambulavero in medio umbrae mortis,
169
+ non timebo mala, quoniam tu mecum es:
170
+ virga tua et baculus tuus ipsa me consolata sunt.
171
+ EOF
172
+ test_expect_success " merge conflicting with --union" \
173
+ " git merge-file --union test.txt orig.txt new3.txt && test_cmp test.txt expect.txt"
174
+ cp backup.txt test.txt
175
+
110
176
test_expect_success " merge with conflicts, using -L" \
111
177
" test_must_fail git merge-file -L 1 -L 2 test.txt orig.txt new3.txt"
112
178
@@ -260,4 +326,23 @@ test_expect_success 'marker size' '
260
326
test_cmp expect actual
261
327
'
262
328
329
+ printf " line1\nline2\nline3" > nolf-orig.txt
330
+ printf " line1\nline2\nline3x" > nolf-diff1.txt
331
+ printf " line1\nline2\nline3y" > nolf-diff2.txt
332
+
333
+ test_expect_success ' conflict at EOF without LF resolved by --ours' \
334
+ ' git merge-file -p --ours nolf-diff1.txt nolf-orig.txt nolf-diff2.txt >output.txt &&
335
+ printf "line1\nline2\nline3x" >expect.txt &&
336
+ test_cmp expect.txt output.txt'
337
+
338
+ test_expect_success ' conflict at EOF without LF resolved by --theirs' \
339
+ ' git merge-file -p --theirs nolf-diff1.txt nolf-orig.txt nolf-diff2.txt >output.txt &&
340
+ printf "line1\nline2\nline3y" >expect.txt &&
341
+ test_cmp expect.txt output.txt'
342
+
343
+ test_expect_success ' conflict at EOF without LF resolved by --union' \
344
+ ' git merge-file -p --union nolf-diff1.txt nolf-orig.txt nolf-diff2.txt >output.txt &&
345
+ printf "line1\nline2\nline3x\nline3y" >expect.txt &&
346
+ test_cmp expect.txt output.txt'
347
+
263
348
test_done
0 commit comments