From 5e3697039e3b7c0cd63b2c75f9a6aa6e03bdf301 Mon Sep 17 00:00:00 2001 From: Igor Karatayev Date: Tue, 31 Mar 2020 11:46:51 +0300 Subject: [PATCH 01/16] enumerate diff lines in patch changeset. --- LibGit2Sharp/ContentChangeLine.cs | 18 ++++++++++++++ LibGit2Sharp/ContentChanges.cs | 40 ++++++++++++++++++++++++------- LibGit2Sharp/LibGit2Sharp.csproj | 2 +- LibGit2Sharp/Patch.cs | 4 ++-- 4 files changed, 52 insertions(+), 12 deletions(-) create mode 100644 LibGit2Sharp/ContentChangeLine.cs diff --git a/LibGit2Sharp/ContentChangeLine.cs b/LibGit2Sharp/ContentChangeLine.cs new file mode 100644 index 000000000..90c3f95c0 --- /dev/null +++ b/LibGit2Sharp/ContentChangeLine.cs @@ -0,0 +1,18 @@ +using LibGit2Sharp.Core; + +namespace LibGit2Sharp +{ + public class ContentChangeLine + { + public int OldLineNo; + public int NewLineNo; + public int NumLines; + + internal ContentChangeLine(GitDiffLine line) + { + OldLineNo = line.OldLineNo; + NewLineNo = line.NewLineNo; + NumLines = line.NumLines; + } + } +} diff --git a/LibGit2Sharp/ContentChanges.cs b/LibGit2Sharp/ContentChanges.cs index 221c99efa..f88f39585 100644 --- a/LibGit2Sharp/ContentChanges.cs +++ b/LibGit2Sharp/ContentChanges.cs @@ -1,4 +1,6 @@ using System; +using System.Collections; +using System.Collections.Generic; using System.Diagnostics; using System.Globalization; using System.Text; @@ -10,9 +12,10 @@ namespace LibGit2Sharp /// Holds the changes between two s. /// [DebuggerDisplay("{DebuggerDisplay,nq}")] - public class ContentChanges + public class ContentChanges : IEnumerable { private readonly StringBuilder patchBuilder = new StringBuilder(); + private readonly List lines = new List(); /// /// Needed for mocking purposes. @@ -95,15 +98,7 @@ private unsafe int LineCallback(git_diff_delta* delta, GitDiffHunk hunk, GitDiff switch (line.lineOrigin) { case GitDiffLineOrigin.GIT_DIFF_LINE_ADDITION: - LinesAdded++; - prefix = Encoding.ASCII.GetString(new[] { (byte)line.lineOrigin }); - break; - case GitDiffLineOrigin.GIT_DIFF_LINE_DELETION: - LinesDeleted++; - prefix = Encoding.ASCII.GetString(new[] { (byte)line.lineOrigin }); - break; - case GitDiffLineOrigin.GIT_DIFF_LINE_CONTEXT: prefix = Encoding.ASCII.GetString(new[] { (byte)line.lineOrigin }); break; @@ -113,11 +108,38 @@ private unsafe int LineCallback(git_diff_delta* delta, GitDiffHunk hunk, GitDiff break; } + AppendGitDiffLine(line); AppendToPatch(prefix); AppendToPatch(decodedContent); return 0; } + internal void AppendGitDiffLine(GitDiffLine line) + { + switch (line.lineOrigin) + { + case GitDiffLineOrigin.GIT_DIFF_LINE_ADDITION: + LinesAdded++; + lines.Add(new ContentChangeLine(line)); + break; + + case GitDiffLineOrigin.GIT_DIFF_LINE_DELETION: + LinesDeleted++; + lines.Add(new ContentChangeLine(line)); + break; + } + } + + public IEnumerator GetEnumerator() + { + return lines.GetEnumerator(); + } + + IEnumerator IEnumerable.GetEnumerator() + { + return lines.GetEnumerator(); + } + private string DebuggerDisplay { get diff --git a/LibGit2Sharp/LibGit2Sharp.csproj b/LibGit2Sharp/LibGit2Sharp.csproj index 77971ea06..f010efc45 100644 --- a/LibGit2Sharp/LibGit2Sharp.csproj +++ b/LibGit2Sharp/LibGit2Sharp.csproj @@ -32,7 +32,7 @@ - + diff --git a/LibGit2Sharp/Patch.cs b/LibGit2Sharp/Patch.cs index 2cd4d1605..04d7ab8d1 100644 --- a/LibGit2Sharp/Patch.cs +++ b/LibGit2Sharp/Patch.cs @@ -76,17 +76,17 @@ private unsafe int PrintCallBack(git_diff_delta* delta, GitDiffHunk hunk, GitDif case GitDiffLineOrigin.GIT_DIFF_LINE_ADDITION: linesAdded++; - currentChange.LinesAdded++; prefix = "+"; break; case GitDiffLineOrigin.GIT_DIFF_LINE_DELETION: linesDeleted++; - currentChange.LinesDeleted++; prefix = "-"; break; } + currentChange.AppendGitDiffLine(line); + string formattedOutput = string.Concat(prefix, patchPart); fullPatchBuilder.Append(formattedOutput); From d522310b0018db985465bac671bfd64f8a48e10a Mon Sep 17 00:00:00 2001 From: Igor Karatayev Date: Mon, 6 Apr 2020 23:33:17 +0300 Subject: [PATCH 02/16] rebase with submodules fixed. --- LibGit2Sharp/LibGit2Sharp.csproj | 1 + LibGit2Sharp/Rebase.cs | 74 ++++++++++++++++++++++++----- LibGit2Sharp/SubmoduleCollection.cs | 7 +++ 3 files changed, 71 insertions(+), 11 deletions(-) diff --git a/LibGit2Sharp/LibGit2Sharp.csproj b/LibGit2Sharp/LibGit2Sharp.csproj index f010efc45..fbfa45c94 100644 --- a/LibGit2Sharp/LibGit2Sharp.csproj +++ b/LibGit2Sharp/LibGit2Sharp.csproj @@ -18,6 +18,7 @@ ..\libgit2sharp.snk square-logo.png App_Readme/LICENSE.md + false diff --git a/LibGit2Sharp/Rebase.cs b/LibGit2Sharp/Rebase.cs index 00dc3f267..d22e7b8ae 100644 --- a/LibGit2Sharp/Rebase.cs +++ b/LibGit2Sharp/Rebase.cs @@ -69,6 +69,56 @@ unsafe AnnotatedCommitHandle AnnotatedCommitHandleFromRefHandle(ReferenceHandle Proxy.git_annotated_commit_from_ref(this.repository.Handle, refHandle); } + ReferenceHandle RefHandleFrom(Branch b) => + (b == null) ? null : this.repository.Refs.RetrieveReferencePtr(b.CanonicalName); + + ReferenceHandle RefHandleFrom(string name) => + (name == null) ? null : this.repository.Refs.RetrieveReferencePtr(name); + + class RebaseReferenceGuard : IDisposable + { + Reference rf; + Action disposeFn; + + public RebaseReferenceGuard(Reference rf_, Action disposeFn_) + { + rf = rf_; + disposeFn = disposeFn_; + } + + public string CanonicalName => rf.CanonicalName; + + public void Dispose() + { + disposeFn(rf); + } + } + + RebaseReferenceGuard ReferenceFrom(Commit c) + { + if (c == null) + return null; + + var rfname = $"refs/rebase/{c.Sha}"; + var rf = this.repository.Refs.Resolve(rfname); + rf = rf ?? this.repository.Refs.Add(rfname, c.Id); + + return new RebaseReferenceGuard(rf, r => { try { this.repository.Refs.Remove(r); } catch { }}); + } + + public virtual RebaseResult Start(Commit annotated, Commit upstream, Commit onto, Identity committer, RebaseOptions options) + { + Ensure.ArgumentNotNull(upstream, "upstream"); + + // TODO: Rebase does not work with just references, is that a bug or design feature? + using (var annotatedRef = ReferenceFrom(annotated)) + using (var upstreamRef = ReferenceFrom(upstream)) + using (var ontoRef = ReferenceFrom(onto)) + using (ReferenceHandle annotatedRefPtr = RefHandleFrom(annotatedRef?.CanonicalName)) + using (ReferenceHandle upstreamRefPtr = RefHandleFrom(upstreamRef?.CanonicalName)) + using (ReferenceHandle ontoRefPtr = RefHandleFrom(ontoRef?.CanonicalName)) + return Start(annotatedRefPtr, upstreamRefPtr, ontoRefPtr, committer, options); + } /// /// Start a rebase operation. /// @@ -82,6 +132,16 @@ public virtual RebaseResult Start(Branch branch, Branch upstream, Branch onto, I { Ensure.ArgumentNotNull(upstream, "upstream"); + using (ReferenceHandle branchRefPtr = RefHandleFrom(branch)) + using (ReferenceHandle upstreamRefPtr = RefHandleFrom(upstream)) + using (ReferenceHandle ontoRefPtr = RefHandleFrom(onto)) + return Start(branchRefPtr, upstreamRefPtr, ontoRefPtr, committer, options); + } + + internal virtual RebaseResult Start(ReferenceHandle annotatedRefPtr, ReferenceHandle upstreamRefPtr, ReferenceHandle ontoRefPtr, Identity committer, RebaseOptions options) + { + Ensure.ArgumentNotNull(upstreamRefPtr, "upstream"); + options = options ?? new RebaseOptions(); EnsureNonBareRepo(); @@ -92,13 +152,6 @@ public virtual RebaseResult Start(Branch branch, Branch upstream, Branch onto, I this.repository.Info.CurrentOperation); } - Func RefHandleFromBranch = (Branch b) => - { - return (b == null) ? - null : - this.repository.Refs.RetrieveReferencePtr(b.CanonicalName); - }; - using (GitCheckoutOptsWrapper checkoutOptionsWrapper = new GitCheckoutOptsWrapper(options)) { GitRebaseOptions gitRebaseOptions = new GitRebaseOptions() @@ -107,10 +160,7 @@ public virtual RebaseResult Start(Branch branch, Branch upstream, Branch onto, I checkout_options = checkoutOptionsWrapper.Options, }; - using (ReferenceHandle branchRefPtr = RefHandleFromBranch(branch)) - using (ReferenceHandle upstreamRefPtr = RefHandleFromBranch(upstream)) - using (ReferenceHandle ontoRefPtr = RefHandleFromBranch(onto)) - using (AnnotatedCommitHandle annotatedBranchCommitHandle = AnnotatedCommitHandleFromRefHandle(branchRefPtr)) + using (AnnotatedCommitHandle annotatedBranchCommitHandle = AnnotatedCommitHandleFromRefHandle(annotatedRefPtr)) using (AnnotatedCommitHandle upstreamRefAnnotatedCommitHandle = AnnotatedCommitHandleFromRefHandle(upstreamRefPtr)) using (AnnotatedCommitHandle ontoRefAnnotatedCommitHandle = AnnotatedCommitHandleFromRefHandle(ontoRefPtr)) using (RebaseHandle rebaseOperationHandle = Proxy.git_rebase_init(this.repository.Handle, @@ -119,6 +169,8 @@ public virtual RebaseResult Start(Branch branch, Branch upstream, Branch onto, I ontoRefAnnotatedCommitHandle, gitRebaseOptions)) { + this.repository.Submodules.UpdateAll(new SubmoduleUpdateOptions()); + RebaseResult rebaseResult = RebaseOperationImpl.Run(rebaseOperationHandle, this.repository, committer, diff --git a/LibGit2Sharp/SubmoduleCollection.cs b/LibGit2Sharp/SubmoduleCollection.cs index fc508107a..ab1461258 100644 --- a/LibGit2Sharp/SubmoduleCollection.cs +++ b/LibGit2Sharp/SubmoduleCollection.cs @@ -70,6 +70,13 @@ public virtual void Init(string name, bool overwrite) } } + + public virtual void UpdateAll(SubmoduleUpdateOptions options) + { + foreach (var sm in this) + Update(sm.Name, options); + } + /// /// Update specified submodule. /// From 0041df5baa8586f4e32388502b208102d7911456 Mon Sep 17 00:00:00 2001 From: Igor Karatayev Date: Fri, 10 Apr 2020 14:51:58 +0300 Subject: [PATCH 03/16] added Common.props --- LibGit2Sharp.Tests/LibGit2Sharp.Tests.csproj | 2 ++ LibGit2Sharp/LibGit2Sharp.csproj | 2 ++ .../x64/NativeLibraryLoadTestApp.x64.csproj | 2 ++ .../x86/NativeLibraryLoadTestApp.x86.csproj | 2 ++ 4 files changed, 8 insertions(+) diff --git a/LibGit2Sharp.Tests/LibGit2Sharp.Tests.csproj b/LibGit2Sharp.Tests/LibGit2Sharp.Tests.csproj index 4a73bd401..ccf7b7e19 100644 --- a/LibGit2Sharp.Tests/LibGit2Sharp.Tests.csproj +++ b/LibGit2Sharp.Tests/LibGit2Sharp.Tests.csproj @@ -1,5 +1,7 @@  + + net46;netcoreapp2.1 diff --git a/LibGit2Sharp/LibGit2Sharp.csproj b/LibGit2Sharp/LibGit2Sharp.csproj index fbfa45c94..cdf64c764 100644 --- a/LibGit2Sharp/LibGit2Sharp.csproj +++ b/LibGit2Sharp/LibGit2Sharp.csproj @@ -1,5 +1,7 @@  + + netstandard2.0;net46 true diff --git a/NativeLibraryLoadTestApp/x64/NativeLibraryLoadTestApp.x64.csproj b/NativeLibraryLoadTestApp/x64/NativeLibraryLoadTestApp.x64.csproj index 5fb7e1b0c..bbc947104 100644 --- a/NativeLibraryLoadTestApp/x64/NativeLibraryLoadTestApp.x64.csproj +++ b/NativeLibraryLoadTestApp/x64/NativeLibraryLoadTestApp.x64.csproj @@ -1,5 +1,7 @@  + + Exe net46 diff --git a/NativeLibraryLoadTestApp/x86/NativeLibraryLoadTestApp.x86.csproj b/NativeLibraryLoadTestApp/x86/NativeLibraryLoadTestApp.x86.csproj index c7bef05c9..2384cbd77 100644 --- a/NativeLibraryLoadTestApp/x86/NativeLibraryLoadTestApp.x86.csproj +++ b/NativeLibraryLoadTestApp/x86/NativeLibraryLoadTestApp.x86.csproj @@ -1,5 +1,7 @@  + + Exe net46 From d8ab449f49bc7028adad8d346e215f50b7a5ffc6 Mon Sep 17 00:00:00 2001 From: Igor Karatayev Date: Sat, 25 Apr 2020 22:27:32 +0300 Subject: [PATCH 04/16] Exception is thrown if file path is passed as remote to Commands.Fetch --- LibGit2Sharp/Core/Proxy.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/LibGit2Sharp/Core/Proxy.cs b/LibGit2Sharp/Core/Proxy.cs index c3a53b95e..a4115f058 100644 --- a/LibGit2Sharp/Core/Proxy.cs +++ b/LibGit2Sharp/Core/Proxy.cs @@ -2373,8 +2373,9 @@ public static unsafe RemoteHandle git_remote_lookup(RepositoryHandle repo, strin git_remote* handle; int res = NativeMethods.git_remote_lookup(out handle, repo, name); - if (res == (int)GitErrorCode.NotFound && !throwsIfNotFound) + if (!throwsIfNotFound) { + if (res == (int)GitErrorCode.NotFound || res == (int)GitErrorCode.InvalidSpecification) return null; } From 8967743a4680cc59f1a82b296d961cd3e31a7e8b Mon Sep 17 00:00:00 2001 From: Igor Karatayev Date: Sat, 25 Apr 2020 22:36:45 +0300 Subject: [PATCH 05/16] In case of reabese of repository with submodules, submodules are left in non updatred state and prevent rebase from continuing. Fixed that by updating submodules after rebase was initialized. --- LibGit2Sharp/Rebase.cs | 2 ++ LibGit2Sharp/SubmoduleCollection.cs | 7 +++++++ 2 files changed, 9 insertions(+) diff --git a/LibGit2Sharp/Rebase.cs b/LibGit2Sharp/Rebase.cs index 00dc3f267..0fe5011ab 100644 --- a/LibGit2Sharp/Rebase.cs +++ b/LibGit2Sharp/Rebase.cs @@ -119,6 +119,8 @@ public virtual RebaseResult Start(Branch branch, Branch upstream, Branch onto, I ontoRefAnnotatedCommitHandle, gitRebaseOptions)) { + this.repository.Submodules.UpdateAll(new SubmoduleUpdateOptions()); + RebaseResult rebaseResult = RebaseOperationImpl.Run(rebaseOperationHandle, this.repository, committer, diff --git a/LibGit2Sharp/SubmoduleCollection.cs b/LibGit2Sharp/SubmoduleCollection.cs index fc508107a..ab1461258 100644 --- a/LibGit2Sharp/SubmoduleCollection.cs +++ b/LibGit2Sharp/SubmoduleCollection.cs @@ -70,6 +70,13 @@ public virtual void Init(string name, bool overwrite) } } + + public virtual void UpdateAll(SubmoduleUpdateOptions options) + { + foreach (var sm in this) + Update(sm.Name, options); + } + /// /// Update specified submodule. /// From 2dc649ed080907e477b3cc99034ba34a1f63025b Mon Sep 17 00:00:00 2001 From: Igor Karatayev Date: Thu, 4 Jun 2020 16:15:51 +0300 Subject: [PATCH 06/16] Added SubmoduleUpdateOptions to rebase options. --- LibGit2Sharp/Rebase.cs | 2 +- LibGit2Sharp/RebaseOptions.cs | 5 +++++ LibGit2Sharp/SubmoduleCollection.cs | 2 ++ 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/LibGit2Sharp/Rebase.cs b/LibGit2Sharp/Rebase.cs index 0fe5011ab..224f7a696 100644 --- a/LibGit2Sharp/Rebase.cs +++ b/LibGit2Sharp/Rebase.cs @@ -119,7 +119,7 @@ public virtual RebaseResult Start(Branch branch, Branch upstream, Branch onto, I ontoRefAnnotatedCommitHandle, gitRebaseOptions)) { - this.repository.Submodules.UpdateAll(new SubmoduleUpdateOptions()); + this.repository.Submodules.UpdateAll(options.SubmoduleUpdateOptions); RebaseResult rebaseResult = RebaseOperationImpl.Run(rebaseOperationHandle, this.repository, diff --git a/LibGit2Sharp/RebaseOptions.cs b/LibGit2Sharp/RebaseOptions.cs index 62cb6cbdb..698f3723d 100644 --- a/LibGit2Sharp/RebaseOptions.cs +++ b/LibGit2Sharp/RebaseOptions.cs @@ -41,6 +41,11 @@ public sealed class RebaseOptions : IConvertableToGitCheckoutOpts /// public CheckoutFileConflictStrategy FileConflictStrategy { get; set; } + /// + /// Submodule update options passed to submodule updates on rtebase step. + /// + public SubmoduleUpdateOptions SubmoduleUpdateOptions { get; set; } + CheckoutCallbacks IConvertableToGitCheckoutOpts.GenerateCallbacks() { return CheckoutCallbacks.From(OnCheckoutProgress, OnCheckoutNotify); diff --git a/LibGit2Sharp/SubmoduleCollection.cs b/LibGit2Sharp/SubmoduleCollection.cs index ab1461258..dd66400e2 100644 --- a/LibGit2Sharp/SubmoduleCollection.cs +++ b/LibGit2Sharp/SubmoduleCollection.cs @@ -73,6 +73,8 @@ public virtual void Init(string name, bool overwrite) public virtual void UpdateAll(SubmoduleUpdateOptions options) { + options = options ?? new SubmoduleUpdateOptions(); + foreach (var sm in this) Update(sm.Name, options); } From 64f6962b2bf1dd97575c69c71335575790ba5e03 Mon Sep 17 00:00:00 2001 From: Igor Karatayev Date: Tue, 9 Jun 2020 13:21:42 +0300 Subject: [PATCH 07/16] Update RebaseOptions.cs --- LibGit2Sharp/RebaseOptions.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/LibGit2Sharp/RebaseOptions.cs b/LibGit2Sharp/RebaseOptions.cs index 698f3723d..301b9099e 100644 --- a/LibGit2Sharp/RebaseOptions.cs +++ b/LibGit2Sharp/RebaseOptions.cs @@ -42,7 +42,7 @@ public sealed class RebaseOptions : IConvertableToGitCheckoutOpts public CheckoutFileConflictStrategy FileConflictStrategy { get; set; } /// - /// Submodule update options passed to submodule updates on rtebase step. + /// Submodule update options passed to submodule updates on rebase step. /// public SubmoduleUpdateOptions SubmoduleUpdateOptions { get; set; } From 12d28e48c4c37533a8df9461df6f077aa1965e98 Mon Sep 17 00:00:00 2001 From: Igor Karatayev Date: Thu, 17 Dec 2020 16:31:30 +0300 Subject: [PATCH 08/16] update. --- LibGit2Sharp/LibGit2Sharp.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/LibGit2Sharp/LibGit2Sharp.csproj b/LibGit2Sharp/LibGit2Sharp.csproj index 77971ea06..22e9ad14e 100644 --- a/LibGit2Sharp/LibGit2Sharp.csproj +++ b/LibGit2Sharp/LibGit2Sharp.csproj @@ -32,7 +32,7 @@ - + From b36c4105fae13c1d5cc5889e8187cc7d667b55e7 Mon Sep 17 00:00:00 2001 From: Igor Karatayev Date: Fri, 29 Jan 2021 18:45:37 +0300 Subject: [PATCH 09/16] update. --- LibGit2Sharp/LibGit2Sharp.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/LibGit2Sharp/LibGit2Sharp.csproj b/LibGit2Sharp/LibGit2Sharp.csproj index 1773312c6..15d419df6 100644 --- a/LibGit2Sharp/LibGit2Sharp.csproj +++ b/LibGit2Sharp/LibGit2Sharp.csproj @@ -37,7 +37,7 @@ - + From 45df744e2fd202423d72cfcdf4f6a4ade53414b7 Mon Sep 17 00:00:00 2001 From: Igor Karatayev Date: Fri, 15 Oct 2021 16:50:24 +0300 Subject: [PATCH 10/16] Update to netstandard 2.1 --- LibGit2Sharp/LibGit2Sharp.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/LibGit2Sharp/LibGit2Sharp.csproj b/LibGit2Sharp/LibGit2Sharp.csproj index 15d419df6..bf39c0d15 100644 --- a/LibGit2Sharp/LibGit2Sharp.csproj +++ b/LibGit2Sharp/LibGit2Sharp.csproj @@ -3,7 +3,7 @@ - netstandard2.0;netcoreapp2.1 + netstandard2.1;netcoreapp2.1 true LibGit2Sharp brings all the might and speed of libgit2, a native Git implementation, to the managed world of .Net and Mono. LibGit2Sharp contributors From 105362350e8a81578389ffe251791886c7a033a1 Mon Sep 17 00:00:00 2001 From: Igor Karatayev Date: Thu, 10 Mar 2022 22:30:42 +0300 Subject: [PATCH 11/16] fixed for net472 --- LibGit2Sharp/Core/NativeMethods.cs | 2 +- LibGit2Sharp/LibGit2Sharp.csproj | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/LibGit2Sharp/Core/NativeMethods.cs b/LibGit2Sharp/Core/NativeMethods.cs index 8c24cff3a..b56bee28d 100644 --- a/LibGit2Sharp/Core/NativeMethods.cs +++ b/LibGit2Sharp/Core/NativeMethods.cs @@ -66,7 +66,7 @@ private static string GetGlobalSettingsNativeLibraryPath() return Path.Combine(nativeLibraryDir, libgit2 + Platform.GetNativeLibraryExtension()); } -#if NETSTANDARD +#if NETSTANDARD || NET47_OR_GREATER private static bool TryUseNativeLibrary() => false; #else private static bool TryUseNativeLibrary() diff --git a/LibGit2Sharp/LibGit2Sharp.csproj b/LibGit2Sharp/LibGit2Sharp.csproj index 721887865..c0c9b1fc6 100644 --- a/LibGit2Sharp/LibGit2Sharp.csproj +++ b/LibGit2Sharp/LibGit2Sharp.csproj @@ -3,7 +3,7 @@ - netstandard2.1;netcoreapp3.1 + netstandard2.1;netcoreapp3.1;net472;net50;net60 true LibGit2Sharp brings all the might and speed of libgit2, a native Git implementation, to the managed world of .NET LibGit2Sharp contributors @@ -35,7 +35,7 @@ - + From 4ff7a44a8f288864e268a52cafb88439f70b34f7 Mon Sep 17 00:00:00 2001 From: Brandon Ording Date: Fri, 1 Apr 2022 19:28:51 -0400 Subject: [PATCH 12/16] Update LibGit2Sharp.NativeBinaries to 2.0.315 This is libgit2 1.4.2 --- LibGit2Sharp/LibGit2Sharp.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/LibGit2Sharp/LibGit2Sharp.csproj b/LibGit2Sharp/LibGit2Sharp.csproj index 57c81cdfb..f710d993a 100644 --- a/LibGit2Sharp/LibGit2Sharp.csproj +++ b/LibGit2Sharp/LibGit2Sharp.csproj @@ -30,7 +30,7 @@ - + From e097d0b3e65009d97518ea74ceaf5bf80ee5a9b6 Mon Sep 17 00:00:00 2001 From: Brandon Ording Date: Sat, 2 Apr 2022 00:07:13 -0400 Subject: [PATCH 13/16] React to ABI changes --- LibGit2Sharp/Core/GitFetchOptions.cs | 1 + LibGit2Sharp/Core/GitPushOptions.cs | 1 + LibGit2Sharp/Core/GitStatusOptions.cs | 2 ++ LibGit2Sharp/Core/GitWorktree.cs | 4 ++-- LibGit2Sharp/Core/RemoteFollowRedirects.cs | 10 ++++++++ LibGit2Sharp/WorktreeCollection.cs | 28 +++++++++++----------- 6 files changed, 30 insertions(+), 16 deletions(-) create mode 100644 LibGit2Sharp/Core/RemoteFollowRedirects.cs diff --git a/LibGit2Sharp/Core/GitFetchOptions.cs b/LibGit2Sharp/Core/GitFetchOptions.cs index 3f0baa2c2..ec924cfe6 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 RemoteFollowRedirects FollowRedirects; public GitStrArrayManaged CustomHeaders; } } diff --git a/LibGit2Sharp/Core/GitPushOptions.cs b/LibGit2Sharp/Core/GitPushOptions.cs index f733534d2..a832a5f3d 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 RemoteFollowRedirects FollowRedirects; public GitStrArrayManaged CustomHeaders; } } diff --git a/LibGit2Sharp/Core/GitStatusOptions.cs b/LibGit2Sharp/Core/GitStatusOptions.cs index d577cefe6..d634fd20b 100644 --- a/LibGit2Sharp/Core/GitStatusOptions.cs +++ b/LibGit2Sharp/Core/GitStatusOptions.cs @@ -15,6 +15,8 @@ internal class GitStatusOptions : IDisposable public IntPtr Baseline = IntPtr.Zero; + public ushort RenameThreshold = 50; + public void Dispose() { PathSpec.Dispose(); diff --git a/LibGit2Sharp/Core/GitWorktree.cs b/LibGit2Sharp/Core/GitWorktree.cs index c71cb16c0..669038f68 100644 --- a/LibGit2Sharp/Core/GitWorktree.cs +++ b/LibGit2Sharp/Core/GitWorktree.cs @@ -1,7 +1,5 @@ using System; -using System.Collections.Generic; using System.Runtime.InteropServices; -using System.Text; namespace LibGit2Sharp.Core { @@ -37,6 +35,8 @@ internal class git_worktree_add_options public int locked; public IntPtr @ref = IntPtr.Zero; + + public GitCheckoutOpts checkout_options; } [StructLayout(LayoutKind.Sequential)] diff --git a/LibGit2Sharp/Core/RemoteFollowRedirects.cs b/LibGit2Sharp/Core/RemoteFollowRedirects.cs new file mode 100644 index 000000000..387d41a75 --- /dev/null +++ b/LibGit2Sharp/Core/RemoteFollowRedirects.cs @@ -0,0 +1,10 @@ +namespace LibGit2Sharp.Core +{ + internal enum RemoteFollowRedirects + { + Unspecified = 0, + None = 1, + Initial = 2, + All = 4 + } +} diff --git a/LibGit2Sharp/WorktreeCollection.cs b/LibGit2Sharp/WorktreeCollection.cs index 9822e882c..42d459b11 100644 --- a/LibGit2Sharp/WorktreeCollection.cs +++ b/LibGit2Sharp/WorktreeCollection.cs @@ -1,12 +1,10 @@ -using LibGit2Sharp.Core; -using LibGit2Sharp.Core.Handles; -using System; +using System; using System.Collections; using System.Collections.Generic; using System.Globalization; -using System.IO; using System.Linq; -using System.Text; +using LibGit2Sharp.Core; +using LibGit2Sharp.Core.Handles; namespace LibGit2Sharp { @@ -48,7 +46,7 @@ public virtual Worktree this[string name] } /// - /// + /// /// /// /// @@ -57,7 +55,7 @@ public virtual Worktree this[string name] /// public virtual Worktree Add(string committishOrBranchSpec, string name, string path, bool isLocked) { - if(string.Equals(committishOrBranchSpec, name)) + if (string.Equals(committishOrBranchSpec, name)) { // Proxy.git_worktree_add() creates a new branch of name = name, so if we want to checkout a given branch then the 'name' cannot be the same as the target branch return null; @@ -66,7 +64,8 @@ public virtual Worktree Add(string committishOrBranchSpec, string name, string p git_worktree_add_options options = new git_worktree_add_options { version = 1, - locked = Convert.ToInt32(isLocked) + locked = Convert.ToInt32(isLocked), + checkout_options = new GitCheckoutOpts { version = 1 } }; using (var handle = Proxy.git_worktree_add(repo.Handle, name, path, options)) @@ -83,13 +82,13 @@ public virtual Worktree Add(string committishOrBranchSpec, string name, string p } } - - return this[name]; + + return this[name]; } /// - /// + /// /// /// /// @@ -99,7 +98,8 @@ public virtual Worktree Add(string name, string path, bool isLocked) git_worktree_add_options options = new git_worktree_add_options { version = 1, - locked = Convert.ToInt32(isLocked) + locked = Convert.ToInt32(isLocked), + checkout_options = new GitCheckoutOpts { version = 1 } }; using (var handle = Proxy.git_worktree_add(repo.Handle, name, path, options)) @@ -112,7 +112,7 @@ public virtual Worktree Add(string name, string path, bool isLocked) } /// - /// + /// /// /// /// @@ -122,7 +122,7 @@ public virtual bool Prune(Worktree worktree) } /// - /// + /// /// /// /// From d79fd3bbcb82089ec12c87133ebba907c49ee57a Mon Sep 17 00:00:00 2001 From: Igor Karatayev Date: Tue, 14 Jun 2022 16:07:43 +0300 Subject: [PATCH 14/16] update --- LibGit2Sharp/LibGit2Sharp.csproj | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/LibGit2Sharp/LibGit2Sharp.csproj b/LibGit2Sharp/LibGit2Sharp.csproj index bf39c0d15..cccd66932 100644 --- a/LibGit2Sharp/LibGit2Sharp.csproj +++ b/LibGit2Sharp/LibGit2Sharp.csproj @@ -36,8 +36,12 @@ - - + + + + + + From 683880fa28566382104d2db171ae88d42d6d9f76 Mon Sep 17 00:00:00 2001 From: Igor Karatayev Date: Tue, 14 Jun 2022 16:36:38 +0300 Subject: [PATCH 15/16] update --- LibGit2Sharp/LibGit2Sharp.csproj | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/LibGit2Sharp/LibGit2Sharp.csproj b/LibGit2Sharp/LibGit2Sharp.csproj index 95b03d507..d15108bf7 100644 --- a/LibGit2Sharp/LibGit2Sharp.csproj +++ b/LibGit2Sharp/LibGit2Sharp.csproj @@ -33,9 +33,9 @@ - + - + From 4eea28e58dadf5875413d65a6538699aa57414e3 Mon Sep 17 00:00:00 2001 From: Igor Karatayev Date: Tue, 14 Jun 2022 16:46:57 +0300 Subject: [PATCH 16/16] update --- LibGit2Sharp/LibGit2Sharp.csproj | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/LibGit2Sharp/LibGit2Sharp.csproj b/LibGit2Sharp/LibGit2Sharp.csproj index c0c9b1fc6..0464490bf 100644 --- a/LibGit2Sharp/LibGit2Sharp.csproj +++ b/LibGit2Sharp/LibGit2Sharp.csproj @@ -33,9 +33,9 @@ - - - + + +