@@ -289,6 +289,31 @@ def test_merge_file_with_labels
289
289
assert_equal merge_file_result [ :path ] , "conflicts-one.txt"
290
290
assert_equal merge_file_result [ :data ] , "<<<<<<< ours\n This is most certainly a conflict!\n =======\n This is a conflict!!!\n >>>>>>> theirs\n "
291
291
end
292
+
293
+ def test_merge_file_without_ancestor
294
+ # remove the stage 1 (ancestor), this is now an add/add conflict
295
+ @repo . index . remove ( "conflicts-one.txt" , 1 )
296
+ merge_file_result = @repo . index . merge_file ( "conflicts-one.txt" , our_label : "ours" , their_label : "theirs" )
297
+ assert !merge_file_result [ :automergeable ]
298
+ assert_equal merge_file_result [ :path ] , "conflicts-one.txt"
299
+ assert_equal merge_file_result [ :data ] , "<<<<<<< ours\n This is most certainly a conflict!\n =======\n This is a conflict!!!\n >>>>>>> theirs\n "
300
+ end
301
+
302
+ def test_merge_file_without_ours
303
+ # turn this into a modify/delete conflict
304
+ @repo . index . remove ( "conflicts-one.txt" , 2 )
305
+ assert_raises RuntimeError do
306
+ @repo . index . merge_file ( "conflicts-one.txt" , our_label : "ours" , their_label : "theirs" )
307
+ end
308
+ end
309
+
310
+ def test_merge_file_without_theirs
311
+ # turn this into a modify/delete conflict
312
+ @repo . index . remove ( "conflicts-one.txt" , 3 )
313
+ assert_raises RuntimeError do
314
+ @repo . index . merge_file ( "conflicts-one.txt" , our_label : "ours" , their_label : "theirs" )
315
+ end
316
+ end
292
317
end
293
318
294
319
class IndexRepositoryTest < Rugged ::TestCase
0 commit comments