@@ -910,9 +910,11 @@ public void CanMergeIntoIndex()
910910 {
911911 var master = repo . Lookup < Commit > ( "master" ) ;
912912
913- Index index = repo . ObjectDatabase . MergeCommitsIntoIndex ( master , master , null ) ;
914- var tree = index . WriteToTree ( ) ;
915- Assert . Equal ( master . Tree . Id , tree . Id ) ;
913+ using ( TransientIndex index = repo . ObjectDatabase . MergeCommitsIntoIndex ( master , master , null ) )
914+ {
915+ var tree = index . WriteToTree ( ) ;
916+ Assert . Equal ( master . Tree . Id , tree . Id ) ;
917+ }
916918 }
917919 }
918920
@@ -925,22 +927,24 @@ public void CanMergeIntoIndexWithConflicts()
925927 var master = repo . Lookup < Commit > ( "master" ) ;
926928 var branch = repo . Lookup < Commit > ( "conflicts" ) ;
927929
928- Index index = repo . ObjectDatabase . MergeCommitsIntoIndex ( branch , master , null ) ;
929- Assert . False ( index . IsFullyMerged ) ;
930+ using ( TransientIndex index = repo . ObjectDatabase . MergeCommitsIntoIndex ( branch , master , null ) )
931+ {
932+ Assert . False ( index . IsFullyMerged ) ;
930933
931- var conflict = index . Conflicts . First ( ) ;
934+ var conflict = index . Conflicts . First ( ) ;
932935
933- //Resolve the conflict by taking the blob from branch
934- var blob = repo . Lookup < Blob > ( conflict . Ours . Id ) ;
935- //Add() does not remove conflict entries for the same path, so they must be explicitly removed first.
936- index . Remove ( conflict . Ours . Path ) ;
937- index . Add ( blob , conflict . Ours . Path , Mode . NonExecutableFile ) ;
936+ //Resolve the conflict by taking the blob from branch
937+ var blob = repo . Lookup < Blob > ( conflict . Ours . Id ) ;
938+ //Add() does not remove conflict entries for the same path, so they must be explicitly removed first.
939+ index . Remove ( conflict . Ours . Path ) ;
940+ index . Add ( blob , conflict . Ours . Path , Mode . NonExecutableFile ) ;
938941
939- Assert . True ( index . IsFullyMerged ) ;
940- var tree = index . WriteToTree ( ) ;
942+ Assert . True ( index . IsFullyMerged ) ;
943+ var tree = index . WriteToTree ( ) ;
941944
942- //Since we took the conflicted blob from the branch, the merged result should be the same as the branch.
943- Assert . Equal ( branch . Tree . Id , tree . Id ) ;
945+ //Since we took the conflicted blob from the branch, the merged result should be the same as the branch.
946+ Assert . Equal ( branch . Tree . Id , tree . Id ) ;
947+ }
944948 }
945949 }
946950
0 commit comments