Skip to content

Commit f43d558

Browse files
committed
Update libgit2 binaries to 98eaf39
libgit2/libgit2@e87d9d3...98eaf39
1 parent cc3197a commit f43d558

File tree

14 files changed

+41
-28
lines changed

14 files changed

+41
-28
lines changed
856 KB
Binary file not shown.
4.5 MB
Binary file not shown.
-850 KB
Binary file not shown.
-4.48 MB
Binary file not shown.
653 KB
Binary file not shown.
4.48 MB
Binary file not shown.
-647 KB
Binary file not shown.
-4.45 MB
Binary file not shown.

LibGit2Sharp/Core/NativeDllName.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@ namespace LibGit2Sharp.Core
22
{
33
internal static class NativeDllName
44
{
5-
public const string Name = "git2-e87d9d3";
5+
public const string Name = "git2-98eaf39";
66
}
77
}

LibGit2Sharp/Core/NativeMethods.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -864,7 +864,7 @@ internal static extern int git_remote_load(
864864
internal delegate int git_headlist_cb(ref GitRemoteHead remoteHeadPtr, IntPtr payload);
865865

866866
[DllImport(libgit2)]
867-
internal static extern int git_remote_ls(RemoteSafeHandle remote, git_headlist_cb headlist_cb, IntPtr payload);
867+
internal static extern int git_remote_ls(out IntPtr heads, out UIntPtr size, RemoteSafeHandle remote);
868868

869869
[DllImport(libgit2)]
870870
[return: MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(LaxUtf8NoCleanupMarshaler))]

LibGit2Sharp/Core/Proxy.cs

Lines changed: 36 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1569,13 +1569,34 @@ public static IList<string> git_remote_list(RepositorySafeHandle repo)
15691569
}
15701570
}
15711571

1572-
public static void git_remote_ls(RemoteSafeHandle remote, NativeMethods.git_headlist_cb headlist_cb)
1572+
public static IEnumerable<DirectReference> git_remote_ls(Repository repository, RemoteSafeHandle remote)
15731573
{
1574+
var refs = new List<DirectReference>();
1575+
IntPtr heads;
1576+
UIntPtr size;
1577+
15741578
using (ThreadAffinity())
15751579
{
1576-
int res = NativeMethods.git_remote_ls(remote, headlist_cb, IntPtr.Zero);
1580+
int res = NativeMethods.git_remote_ls(out heads, out size, remote);
15771581
Ensure.ZeroResult(res);
15781582
}
1583+
1584+
var grheads = Libgit2UnsafeHelper.RemoteLsHelper(heads, size);
1585+
1586+
foreach (var remoteHead in grheads)
1587+
{
1588+
// The name pointer should never be null - if it is,
1589+
// this indicates a bug somewhere (libgit2, server, etc).
1590+
if (remoteHead.NamePtr == IntPtr.Zero)
1591+
{
1592+
throw new InvalidOperationException("Not expecting null value for reference name.");
1593+
}
1594+
1595+
string name = LaxUtf8Marshaler.FromNative(remoteHead.NamePtr);
1596+
refs.Add(new DirectReference(name, repository, remoteHead.Oid));
1597+
}
1598+
1599+
return refs;
15791600
}
15801601

15811602
public static RemoteSafeHandle git_remote_load(RepositorySafeHandle repo, string name, bool throwsIfNotFound)
@@ -2531,6 +2552,19 @@ public static IList<string> BuildListOf(UnSafeNativeMethods.git_strarray strArra
25312552
UnSafeNativeMethods.git_strarray_free(ref strArray);
25322553
}
25332554
}
2555+
2556+
public static IList<GitRemoteHead> RemoteLsHelper(IntPtr heads, UIntPtr size)
2557+
{
2558+
var rawHeads = (IntPtr*) heads;
2559+
var count = (int) size;
2560+
2561+
var list = new List<GitRemoteHead>(count);
2562+
for (int i = 0; i < count; i++)
2563+
{
2564+
list.Add((GitRemoteHead)Marshal.PtrToStructure(rawHeads[i], typeof (GitRemoteHead)));
2565+
}
2566+
return list;
2567+
}
25342568
}
25352569

25362570
private static bool RepositoryStateChecker(RepositorySafeHandle repo, Func<RepositorySafeHandle, int> checker)

LibGit2Sharp/Network.cs

Lines changed: 1 addition & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -67,32 +67,11 @@ public virtual IEnumerable<DirectReference> ListReferences(Remote remote)
6767
{
6868
Ensure.ArgumentNotNull(remote, "remote");
6969

70-
List<DirectReference> directReferences = new List<DirectReference>();
7170
using (RemoteSafeHandle remoteHandle = Proxy.git_remote_load(repository.Handle, remote.Name, true))
7271
{
7372
Proxy.git_remote_connect(remoteHandle, GitDirection.Fetch);
74-
75-
NativeMethods.git_headlist_cb cb = (ref GitRemoteHead remoteHead, IntPtr payload) =>
76-
{
77-
// The name pointer should never be null - if it is,
78-
// this indicates a bug somewhere (libgit2, server, etc).
79-
if (remoteHead.NamePtr == IntPtr.Zero)
80-
{
81-
Proxy.giterr_set_str(GitErrorCategory.Invalid, "Not expecting null value for reference name.");
82-
return -1;
83-
}
84-
85-
ObjectId oid = remoteHead.Oid;
86-
string name = LaxUtf8Marshaler.FromNative(remoteHead.NamePtr);
87-
directReferences.Add(new DirectReference(name, this.repository, oid));
88-
89-
return 0;
90-
};
91-
92-
Proxy.git_remote_ls(remoteHandle, cb);
73+
return Proxy.git_remote_ls(repository, remoteHandle);
9374
}
94-
95-
return directReferences;
9675
}
9776

9877
/// <summary>

LibGit2Sharp/libgit2_hash.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
e87d9d3d4d8de9c048476387931c4ac57d1c2b73
1+
98eaf39a87164eeb284df5c0239c3a31dfb538e7

0 commit comments

Comments
 (0)