@@ -2214,32 +2214,23 @@ public static IList<string> git_remote_list(RepositorySafeHandle repo)
22142214 }
22152215 }
22162216
2217- public static IEnumerable < Reference > git_remote_ls ( Repository repository , RemoteSafeHandle remote )
2217+ public static unsafe IEnumerable < Reference > git_remote_ls ( Repository repository , RemoteSafeHandle remote )
22182218 {
2219- IntPtr heads ;
2219+ git_remote_head * * heads ;
22202220 UIntPtr count ;
22212221
22222222 int res = NativeMethods . git_remote_ls ( out heads , out count , remote ) ;
22232223 Ensure . ZeroResult ( res ) ;
22242224
2225- var intCount = ( int ) count . ToUInt32 ( ) ;
2226-
2227- if ( intCount < 0 )
2228- {
2229- throw new OverflowException ( ) ;
2230- }
2231-
2225+ var intCount = checked ( count . ToUInt32 ( ) ) ;
22322226 var directRefs = new Dictionary < string , Reference > ( ) ;
22332227 var symRefs = new Dictionary < string , string > ( ) ;
22342228
2235- IntPtr currentHead = heads ;
2236-
22372229 for ( int i = 0 ; i < intCount ; i ++ )
22382230 {
2239- var remoteHead = Marshal . ReadIntPtr ( currentHead ) . MarshalAs < GitRemoteHead > ( ) ;
2240-
2241- string name = LaxUtf8Marshaler . FromNative ( remoteHead . NamePtr ) ;
2242- string symRefTarget = LaxUtf8Marshaler . FromNative ( remoteHead . SymRefTargetPtr ) ;
2231+ git_remote_head * currentHead = heads [ i ] ;
2232+ string name = LaxUtf8Marshaler . FromNative ( currentHead ->Name ) ;
2233+ string symRefTarget = LaxUtf8Marshaler . FromNative ( currentHead ->SymrefTarget ) ;
22432234
22442235 // The name pointer should never be null - if it is,
22452236 // this indicates a bug somewhere (libgit2, server, etc).
@@ -2254,10 +2245,8 @@ public static IEnumerable<Reference> git_remote_ls(Repository repository, Remote
22542245 }
22552246 else
22562247 {
2257- directRefs . Add ( name , new DirectReference ( name , repository , remoteHead . Oid ) ) ;
2248+ directRefs . Add ( name , new DirectReference ( name , repository , new ObjectId ( currentHead -> Oid . Id ) ) ) ;
22582249 }
2259-
2260- currentHead = IntPtr . Add ( currentHead , IntPtr . Size ) ;
22612250 }
22622251
22632252 for ( int i = 0 ; i < symRefs . Count ; i ++ )
0 commit comments