@@ -603,22 +603,41 @@ public virtual MergeTreeResult MergeCommits(Commit ours, Commit theirs, MergeTre
603603
604604 options = options ?? new MergeTreeOptions ( ) ;
605605
606+ // We throw away the index after looking at the conflicts, so we'll never need the REUC
607+ // entries to be there
608+ GitMergeFlag mergeFlags = GitMergeFlag . GIT_MERGE_NORMAL | GitMergeFlag . GIT_MERGE_SKIP_REUC ;
609+ if ( options . FindRenames )
610+ {
611+ mergeFlags |= GitMergeFlag . GIT_MERGE_FIND_RENAMES ;
612+ }
613+ if ( options . FailOnConflict )
614+ {
615+ mergeFlags |= GitMergeFlag . GIT_MERGE_FAIL_ON_CONFLICT ;
616+ }
617+
618+
606619 var mergeOptions = new GitMergeOpts
607620 {
608621 Version = 1 ,
609622 MergeFileFavorFlags = options . MergeFileFavor ,
610- MergeTreeFlags = options . FindRenames ? GitMergeFlag . GIT_MERGE_FIND_RENAMES
611- : GitMergeFlag . GIT_MERGE_NORMAL ,
623+ MergeTreeFlags = mergeFlags ,
612624 RenameThreshold = ( uint ) options . RenameThreshold ,
613625 TargetLimit = ( uint ) options . TargetLimit ,
614626 } ;
615627
628+ bool earlyStop ;
616629 using ( var oneHandle = Proxy . git_object_lookup ( repo . Handle , ours . Id , GitObjectType . Commit ) )
617630 using ( var twoHandle = Proxy . git_object_lookup ( repo . Handle , theirs . Id , GitObjectType . Commit ) )
618- using ( var indexHandle = Proxy . git_merge_commits ( repo . Handle , oneHandle , twoHandle , mergeOptions ) )
631+ using ( var indexHandle = Proxy . git_merge_commits ( repo . Handle , oneHandle , twoHandle , mergeOptions , out earlyStop ) )
619632 {
620633 MergeTreeResult mergeResult ;
621634
635+ // Stopped due to FailOnConflict so there's no index or conflict list
636+ if ( earlyStop )
637+ {
638+ return new MergeTreeResult ( new Conflict [ ] { } ) ;
639+ }
640+
622641 if ( Proxy . git_index_has_conflicts ( indexHandle ) )
623642 {
624643 List < Conflict > conflicts = new List < Conflict > ( ) ;
0 commit comments