@@ -485,9 +485,9 @@ internal GitObject Lookup(string objectish, GitObjectType type, LookUpOptions lo
485485 Ensure . ArgumentNotNullOrEmptyString ( objectish , "objectish" ) ;
486486
487487 GitObject obj ;
488- using ( GitObjectSafeHandle sh = Proxy . git_revparse_single ( handle , objectish ) )
488+ using ( DisposableTuple < GitObjectSafeHandle , ReferenceSafeHandle > handles = Proxy . git_revparse_ext ( handle , objectish ) )
489489 {
490- if ( sh == null )
490+ if ( handles == null )
491491 {
492492 if ( lookUpOptions . HasFlag ( LookUpOptions . ThrowWhenNoGitObjectHasBeenFound ) )
493493 {
@@ -497,14 +497,15 @@ internal GitObject Lookup(string objectish, GitObjectType type, LookUpOptions lo
497497 return null ;
498498 }
499499
500- GitObjectType objType = Proxy . git_object_type ( sh ) ;
500+ var objH = handles . Item1 ;
501+ GitObjectType objType = Proxy . git_object_type ( objH ) ;
501502
502503 if ( type != GitObjectType . Any && objType != type )
503504 {
504505 return null ;
505506 }
506507
507- obj = GitObject . BuildFrom ( this , Proxy . git_object_id ( sh ) , objType , PathFromRevparseSpec ( objectish ) ) ;
508+ obj = GitObject . BuildFrom ( this , Proxy . git_object_id ( objH ) , objType , PathFromRevparseSpec ( objectish ) ) ;
508509 }
509510
510511 if ( lookUpOptions . HasFlag ( LookUpOptions . DereferenceResultToCommit ) )
@@ -752,17 +753,18 @@ public Branch Checkout(string committishOrBranchSpec, CheckoutOptions options)
752753 Ensure . ArgumentNotNullOrEmptyString ( committishOrBranchSpec , "committishOrBranchSpec" ) ;
753754 Ensure . ArgumentNotNull ( options , "options" ) ;
754755
755- var handles = Proxy . git_revparse_ext ( Handle , committishOrBranchSpec ) ;
756- if ( handles == null )
757- {
758- Ensure . GitObjectIsNotNull ( null , committishOrBranchSpec ) ;
759- }
760-
761- var objH = handles . Item1 ;
762- var refH = handles . Item2 ;
763756 GitObject obj ;
764- try
757+
758+ using ( DisposableTuple < GitObjectSafeHandle , ReferenceSafeHandle > handles = Proxy . git_revparse_ext ( Handle , committishOrBranchSpec ) )
765759 {
760+ if ( handles == null )
761+ {
762+ Ensure . GitObjectIsNotNull ( null , committishOrBranchSpec ) ;
763+ }
764+
765+ var objH = handles . Item1 ;
766+ var refH = handles . Item2 ;
767+
766768 if ( ! refH . IsInvalid )
767769 {
768770 var reference = Reference . BuildFromPtr < Reference > ( refH , this ) ;
@@ -776,11 +778,6 @@ public Branch Checkout(string committishOrBranchSpec, CheckoutOptions options)
776778 obj = GitObject . BuildFrom ( this , Proxy . git_object_id ( objH ) , Proxy . git_object_type ( objH ) ,
777779 PathFromRevparseSpec ( committishOrBranchSpec ) ) ;
778780 }
779- finally
780- {
781- objH . Dispose ( ) ;
782- refH . Dispose ( ) ;
783- }
784781
785782 Commit commit = obj . DereferenceToCommit ( true ) ;
786783 Checkout ( commit . Tree , options , committishOrBranchSpec ) ;
0 commit comments