From 428f1e0d43aa5fc0ca1fccc0a702025605df65ae Mon Sep 17 00:00:00 2001 From: Gareth Jones Date: Sat, 17 Jun 2023 09:45:39 -0600 Subject: [PATCH 1/2] Set GitProxyOptions type to default to auto --- LibGit2Sharp/Core/GitProxyOptions.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/LibGit2Sharp/Core/GitProxyOptions.cs b/LibGit2Sharp/Core/GitProxyOptions.cs index b62b8e08f..b2a8dc1e0 100644 --- a/LibGit2Sharp/Core/GitProxyOptions.cs +++ b/LibGit2Sharp/Core/GitProxyOptions.cs @@ -11,10 +11,10 @@ internal enum GitProxyType } [StructLayout(LayoutKind.Sequential)] - internal struct GitProxyOptions + internal sealed class GitProxyOptions { public uint Version; - public GitProxyType Type; + public GitProxyType Type = GitProxyType.Auto; public IntPtr Url; public IntPtr CredentialsCb; public IntPtr CertificateCheck; From 2dcc71b6144a8877bc7d079d290d8e4fe46b26d8 Mon Sep 17 00:00:00 2001 From: Gareth Jones Date: Sat, 17 Jun 2023 10:50:28 -0600 Subject: [PATCH 2/2] Fix failing tests --- LibGit2Sharp/Commands/Fetch.cs | 2 +- LibGit2Sharp/Core/GitProxyOptions.cs | 9 +++++++-- LibGit2Sharp/Network.cs | 4 ++-- LibGit2Sharp/Repository.cs | 8 ++++---- LibGit2Sharp/SubmoduleCollection.cs | 2 +- 5 files changed, 15 insertions(+), 10 deletions(-) diff --git a/LibGit2Sharp/Commands/Fetch.cs b/LibGit2Sharp/Commands/Fetch.cs index d61fca5a5..e65373cc0 100644 --- a/LibGit2Sharp/Commands/Fetch.cs +++ b/LibGit2Sharp/Commands/Fetch.cs @@ -75,7 +75,7 @@ public static void Fetch(Repository repository, string remote, IEnumerable ListReferencesInternal(string url, CredentialsHan using (RemoteHandle remoteHandle = BuildRemoteHandle(repository.Handle, url)) { GitRemoteCallbacks gitCallbacks = new GitRemoteCallbacks { version = 1 }; - GitProxyOptions proxyOptions = new GitProxyOptions { Version = 1 }; + GitProxyOptions proxyOptions = GitProxyOptions.CreateGitProxyOptions(); if (credentialsProvider != null) { @@ -375,7 +375,7 @@ public virtual void Push(Remote remote, IEnumerable pushRefSpecs, PushOp { PackbuilderDegreeOfParallelism = pushOptions.PackbuilderDegreeOfParallelism, RemoteCallbacks = gitCallbacks, - ProxyOptions = new GitProxyOptions { Version = 1 }, + ProxyOptions = GitProxyOptions.CreateGitProxyOptions(), }); } } diff --git a/LibGit2Sharp/Repository.cs b/LibGit2Sharp/Repository.cs index 41aaecfbf..eb0f32bc0 100644 --- a/LibGit2Sharp/Repository.cs +++ b/LibGit2Sharp/Repository.cs @@ -678,7 +678,7 @@ public static IEnumerable ListRemoteReferences(string url, Credential using (RemoteHandle remoteHandle = Proxy.git_remote_create_anonymous(repositoryHandle, url)) { var gitCallbacks = new GitRemoteCallbacks { version = 1 }; - var proxyOptions = new GitProxyOptions { Version = 1 }; + var proxyOptions = GitProxyOptions.CreateGitProxyOptions(); if (credentialsProvider != null) { @@ -768,7 +768,7 @@ public static string Clone(string sourceUrl, string workdirPath, var gitCheckoutOptions = checkoutOptionsWrapper.Options; var gitFetchOptions = fetchOptionsWrapper.Options; - gitFetchOptions.ProxyOptions = new GitProxyOptions { Version = 1 }; + gitFetchOptions.ProxyOptions = GitProxyOptions.CreateGitProxyOptions(); gitFetchOptions.RemoteCallbacks = new RemoteCallbacks(options).GenerateCallbacks(); if (options.FetchOptions != null && options.FetchOptions.CustomHeaders != null) { @@ -1050,7 +1050,7 @@ public Commit Commit(string message, Signature author, Signature committer, Comm if (treesame && !amendMergeCommit) { - throw (options.AmendPreviousCommit ? + throw (options.AmendPreviousCommit ? new EmptyCommitException("Amending this commit would produce a commit that is identical to its parent (id = {0})", parents[0].Id) : new EmptyCommitException("No changes; nothing to commit.")); } @@ -1241,7 +1241,7 @@ public MergeResult MergeFetchedRefs(Signature merger, MergeOptions options) if (fetchHeads.Length == 0) { var expectedRef = this.Head.UpstreamBranchCanonicalName; - throw new MergeFetchHeadNotFoundException("The current branch is configured to merge with the reference '{0}' from the remote, but this reference was not fetched.", + throw new MergeFetchHeadNotFoundException("The current branch is configured to merge with the reference '{0}' from the remote, but this reference was not fetched.", expectedRef); } diff --git a/LibGit2Sharp/SubmoduleCollection.cs b/LibGit2Sharp/SubmoduleCollection.cs index fc508107a..ecd6ff833 100644 --- a/LibGit2Sharp/SubmoduleCollection.cs +++ b/LibGit2Sharp/SubmoduleCollection.cs @@ -104,7 +104,7 @@ public virtual void Update(string name, SubmoduleUpdateOptions options) { Version = 1, CheckoutOptions = gitCheckoutOptions, - FetchOptions = new GitFetchOptions { ProxyOptions = new GitProxyOptions { Version = 1 }, RemoteCallbacks = gitRemoteCallbacks }, + FetchOptions = new GitFetchOptions { ProxyOptions = GitProxyOptions.CreateGitProxyOptions(), RemoteCallbacks = gitRemoteCallbacks }, CloneCheckoutStrategy = CheckoutStrategy.GIT_CHECKOUT_SAFE };