From 15af0defee26ca955fbb37460395000e5bf2f92a Mon Sep 17 00:00:00 2001 From: Edward Thomson Date: Thu, 23 Feb 2023 11:33:36 -0800 Subject: [PATCH] LibGit2Sharp: update to libgit2 v1.6.2 --- LibGit2Sharp.Tests/GlobalSettingsFixture.cs | 11 +++----- LibGit2Sharp/Core/GitFetchOptions.cs | 1 + LibGit2Sharp/Core/GitOdbBackend.cs | 6 ++--- LibGit2Sharp/Core/GitPushOptions.cs | 1 + LibGit2Sharp/Core/GitWorktree.cs | 2 ++ LibGit2Sharp/LibGit2Sharp.csproj | 2 +- LibGit2Sharp/RemoteRedirectMode.cs | 28 +++++++++++++++++++++ 7 files changed, 38 insertions(+), 13 deletions(-) create mode 100644 LibGit2Sharp/RemoteRedirectMode.cs diff --git a/LibGit2Sharp.Tests/GlobalSettingsFixture.cs b/LibGit2Sharp.Tests/GlobalSettingsFixture.cs index bd9a53d1b..e067fd192 100644 --- a/LibGit2Sharp.Tests/GlobalSettingsFixture.cs +++ b/LibGit2Sharp.Tests/GlobalSettingsFixture.cs @@ -90,22 +90,17 @@ public void SetExtensions() var extensions = GlobalSettings.GetExtensions(); // Assert that "noop" is supported by default - Assert.Equal(new[] { "noop" }, extensions); + Assert.Equal(new[] { "noop", "objectformat" }, extensions); // Disable "noop" extensions GlobalSettings.SetExtensions("!noop"); extensions = GlobalSettings.GetExtensions(); - Assert.Empty(extensions); + Assert.Equal(new[] { "objectformat" }, extensions); // Enable two new extensions (it will reset the configuration and "noop" will be enabled) GlobalSettings.SetExtensions("partialclone", "newext"); extensions = GlobalSettings.GetExtensions(); - Assert.Equal(new[] { "noop", "partialclone", "newext" }, extensions); - - // You can have multiple times the same extension - GlobalSettings.SetExtensions("noop", "test", "test" ); - extensions = GlobalSettings.GetExtensions(); - Assert.Equal(new[] { "noop", "noop", "test", "test" }, extensions); + Assert.Equal(new[] { "noop", "objectformat", "partialclone", "newext" }, extensions); } } } diff --git a/LibGit2Sharp/Core/GitFetchOptions.cs b/LibGit2Sharp/Core/GitFetchOptions.cs index 3f0baa2c2..bdf8aa585 100644 --- a/LibGit2Sharp/Core/GitFetchOptions.cs +++ b/LibGit2Sharp/Core/GitFetchOptions.cs @@ -11,6 +11,7 @@ internal class GitFetchOptions public bool UpdateFetchHead = true; public TagFetchMode download_tags; public GitProxyOptions ProxyOptions; + public RemoteRedirectMode FollowRedirects = RemoteRedirectMode.Auto; public GitStrArrayManaged CustomHeaders; } } diff --git a/LibGit2Sharp/Core/GitOdbBackend.cs b/LibGit2Sharp/Core/GitOdbBackend.cs index 3ff031048..6f017542d 100644 --- a/LibGit2Sharp/Core/GitOdbBackend.cs +++ b/LibGit2Sharp/Core/GitOdbBackend.cs @@ -33,10 +33,8 @@ static GitOdbBackend() public exists_prefix_callback ExistsPrefix; public IntPtr Refresh; public foreach_callback Foreach; - - private IntPtr Padding; // TODO: add writemidx - - public IntPtr Writepack; + public IntPtr WritePack; + public IntPtr WriteMidx; public IntPtr Freshen; public free_callback Free; diff --git a/LibGit2Sharp/Core/GitPushOptions.cs b/LibGit2Sharp/Core/GitPushOptions.cs index f733534d2..8c98ce9cc 100644 --- a/LibGit2Sharp/Core/GitPushOptions.cs +++ b/LibGit2Sharp/Core/GitPushOptions.cs @@ -9,6 +9,7 @@ internal class GitPushOptions public int PackbuilderDegreeOfParallelism; public GitRemoteCallbacks RemoteCallbacks; public GitProxyOptions ProxyOptions; + public RemoteRedirectMode FollowRedirects = RemoteRedirectMode.Auto; public GitStrArrayManaged CustomHeaders; } } diff --git a/LibGit2Sharp/Core/GitWorktree.cs b/LibGit2Sharp/Core/GitWorktree.cs index c71cb16c0..b3200dd91 100644 --- a/LibGit2Sharp/Core/GitWorktree.cs +++ b/LibGit2Sharp/Core/GitWorktree.cs @@ -37,6 +37,8 @@ internal class git_worktree_add_options public int locked; public IntPtr @ref = IntPtr.Zero; + + public GitCheckoutOpts checkoutOpts = new GitCheckoutOpts { version = 1 }; } [StructLayout(LayoutKind.Sequential)] diff --git a/LibGit2Sharp/LibGit2Sharp.csproj b/LibGit2Sharp/LibGit2Sharp.csproj index 57c81cdfb..03025744f 100644 --- a/LibGit2Sharp/LibGit2Sharp.csproj +++ b/LibGit2Sharp/LibGit2Sharp.csproj @@ -30,7 +30,7 @@ - + diff --git a/LibGit2Sharp/RemoteRedirectMode.cs b/LibGit2Sharp/RemoteRedirectMode.cs new file mode 100644 index 000000000..08866e68a --- /dev/null +++ b/LibGit2Sharp/RemoteRedirectMode.cs @@ -0,0 +1,28 @@ +namespace LibGit2Sharp +{ + /// + /// Remote redirection settings; wehther redirects to another + /// host are permitted. By default, git will follow a redirect + /// on the initial request (`/info/refs`) but not subsequent + /// requests. + /// + public enum RemoteRedirectMode + { + /// + /// Do not follow any off-site redirects at any stage of + /// the fetch or push. + /// + None = 0, // GIT_REMOTE_REDIRECT_NONE + + /// + /// Allow off-site redirects only upon the initial + /// request. This is the default. + /// + Auto, // GIT_REMOTE_REDIRECT_INITIAL + + /// + /// Allow redirects at any stage in the fetch or push. + /// + All // GIT_REMOTE_REDIRECT_ALL + } +}