diff --git a/Lib/NativeBinaries/amd64/git2-90befde.dll b/Lib/NativeBinaries/amd64/git2-e93206e.dll similarity index 51% rename from Lib/NativeBinaries/amd64/git2-90befde.dll rename to Lib/NativeBinaries/amd64/git2-e93206e.dll index 5af4cbce4..fc1a0f2b3 100644 Binary files a/Lib/NativeBinaries/amd64/git2-90befde.dll and b/Lib/NativeBinaries/amd64/git2-e93206e.dll differ diff --git a/Lib/NativeBinaries/amd64/git2-90befde.pdb b/Lib/NativeBinaries/amd64/git2-e93206e.pdb similarity index 55% rename from Lib/NativeBinaries/amd64/git2-90befde.pdb rename to Lib/NativeBinaries/amd64/git2-e93206e.pdb index bc9fb2269..0d0e8825c 100644 Binary files a/Lib/NativeBinaries/amd64/git2-90befde.pdb and b/Lib/NativeBinaries/amd64/git2-e93206e.pdb differ diff --git a/Lib/NativeBinaries/x86/git2-90befde.dll b/Lib/NativeBinaries/x86/git2-e93206e.dll similarity index 58% rename from Lib/NativeBinaries/x86/git2-90befde.dll rename to Lib/NativeBinaries/x86/git2-e93206e.dll index 086bfda98..dcf911480 100644 Binary files a/Lib/NativeBinaries/x86/git2-90befde.dll and b/Lib/NativeBinaries/x86/git2-e93206e.dll differ diff --git a/Lib/NativeBinaries/x86/git2-90befde.pdb b/Lib/NativeBinaries/x86/git2-e93206e.pdb similarity index 60% rename from Lib/NativeBinaries/x86/git2-90befde.pdb rename to Lib/NativeBinaries/x86/git2-e93206e.pdb index 8a6ab03aa..0bef5d390 100644 Binary files a/Lib/NativeBinaries/x86/git2-90befde.pdb and b/Lib/NativeBinaries/x86/git2-e93206e.pdb differ diff --git a/LibGit2Sharp/Core/GitStrArrayOut.cs b/LibGit2Sharp/Core/GitStrArrayOut.cs new file mode 100644 index 000000000..0bc2f6765 --- /dev/null +++ b/LibGit2Sharp/Core/GitStrArrayOut.cs @@ -0,0 +1,47 @@ +using System; +using System.Collections.Generic; +using System.Runtime.InteropServices; + +namespace LibGit2Sharp.Core +{ + [StructLayout(LayoutKind.Sequential)] + internal class GitStrArrayOut : IDisposable + { + public IntPtr strings; + public uint size; + + public IEnumerable Build() + { + int count = (int)size; + var pointers = new IntPtr[count]; + + Marshal.Copy(strings, pointers, 0, count); + + for (int i = 0; i < count; i++) + { + yield return LaxUtf8Marshaler.FromNative(pointers[i]); + } + } + + public void Dispose() + { + if (size == 0) + { + return; + } + + var count = (int)size; + + var pointers = new IntPtr[count]; + Marshal.Copy(strings, pointers, 0, count); + + for (int i = 0; i < count; i++) + { + EncodingMarshaler.Cleanup(pointers[i]); + } + + Marshal.FreeHGlobal(strings); + size = 0; + } + } +} diff --git a/LibGit2Sharp/Core/NativeDllName.cs b/LibGit2Sharp/Core/NativeDllName.cs index 5fd4f2b5a..d68324d85 100644 --- a/LibGit2Sharp/Core/NativeDllName.cs +++ b/LibGit2Sharp/Core/NativeDllName.cs @@ -2,6 +2,6 @@ namespace LibGit2Sharp.Core { internal static class NativeDllName { - public const string Name = "git2-90befde"; + public const string Name = "git2-e93206e"; } } diff --git a/LibGit2Sharp/Core/NativeMethods.cs b/LibGit2Sharp/Core/NativeMethods.cs index 55bbe19a4..9b06c60fb 100644 --- a/LibGit2Sharp/Core/NativeMethods.cs +++ b/LibGit2Sharp/Core/NativeMethods.cs @@ -214,10 +214,9 @@ internal static extern int git_branch_remote_name( [DllImport(libgit2)] internal static extern int git_remote_rename( + GitStrArrayOut problems, RemoteSafeHandle remote, - [MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(StrictUtf8Marshaler))] string new_name, - git_remote_rename_problem_cb callback, - IntPtr payload); + [MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(StrictUtf8Marshaler))] string new_name); internal delegate int git_remote_rename_problem_cb( [MarshalAs(UnmanagedType.CustomMarshaler, MarshalCookie = UniqueId.UniqueIdentifier, MarshalTypeRef = typeof(LaxUtf8NoCleanupMarshaler))] string problematic_refspec, diff --git a/LibGit2Sharp/Core/Proxy.cs b/LibGit2Sharp/Core/Proxy.cs index 3b1cc0294..096b02824 100644 --- a/LibGit2Sharp/Core/Proxy.cs +++ b/LibGit2Sharp/Core/Proxy.cs @@ -1830,7 +1830,6 @@ public static void git_remote_delete(RepositorySafeHandle repo, string name) int res = NativeMethods.git_remote_delete(remote); Ensure.ZeroResult(res); - remote.SetHandleAsInvalid(); } } } @@ -1997,16 +1996,23 @@ public static void git_remote_rename(RepositorySafeHandle repo, string name, str if (callback == null) { - callback = (problem) => {}; + callback = problem => {}; } - int res = NativeMethods.git_remote_rename( - remote, - new_name, - (problem, payload) => { callback(problem); return 0; }, - IntPtr.Zero); + using (var array = new GitStrArrayOut()) + { + int res = NativeMethods.git_remote_rename( + array, + remote, + new_name); - Ensure.ZeroResult(res); + Ensure.ZeroResult(res); + + foreach (var item in array.Build ()) + { + callback(item); + } + } } } } diff --git a/LibGit2Sharp/LibGit2Sharp.csproj b/LibGit2Sharp/LibGit2Sharp.csproj index 85e12cd2f..869f5d026 100644 --- a/LibGit2Sharp/LibGit2Sharp.csproj +++ b/LibGit2Sharp/LibGit2Sharp.csproj @@ -318,6 +318,7 @@ + diff --git a/LibGit2Sharp/libgit2_hash.txt b/LibGit2Sharp/libgit2_hash.txt index 44e16bb22..69a9bd0a8 100644 --- a/LibGit2Sharp/libgit2_hash.txt +++ b/LibGit2Sharp/libgit2_hash.txt @@ -1 +1 @@ -90befde4a1938641dfdb9a7bdb9f361d1de5c26f +e93206e0f5bd9a1f2ad17d0d566b1e815a762420 diff --git a/libgit2 b/libgit2 index 90befde4a..e93206e0f 160000 --- a/libgit2 +++ b/libgit2 @@ -1 +1 @@ -Subproject commit 90befde4a1938641dfdb9a7bdb9f361d1de5c26f +Subproject commit e93206e0f5bd9a1f2ad17d0d566b1e815a762420