From 70d62d5adf6ac951d756d115c6b34b719947a83a Mon Sep 17 00:00:00 2001 From: Edward Thomson Date: Thu, 23 Feb 2023 11:33:36 -0800 Subject: [PATCH 01/21] 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 + } +} From d0d80290360d9400aafc5814ea78ed5050853b48 Mon Sep 17 00:00:00 2001 From: Brandon Ording Date: Fri, 7 Apr 2023 17:13:35 -0400 Subject: [PATCH 02/21] Update LibGit2Sharp.NativeBinaries to 2.0.319 --- LibGit2Sharp/LibGit2Sharp.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/LibGit2Sharp/LibGit2Sharp.csproj b/LibGit2Sharp/LibGit2Sharp.csproj index 03025744f..c81dd7093 100644 --- a/LibGit2Sharp/LibGit2Sharp.csproj +++ b/LibGit2Sharp/LibGit2Sharp.csproj @@ -30,7 +30,7 @@ - + From 1be14ba9a39bffca8b6a272ba780a7b1bdf1119d Mon Sep 17 00:00:00 2001 From: Brandon Ording Date: Fri, 7 Apr 2023 17:33:44 -0400 Subject: [PATCH 03/21] Update action versions --- .github/workflows/ci.yml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 118649aa2..ac62110ec 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -15,17 +15,17 @@ jobs: runs-on: ubuntu-20.04 steps: - name: Checkout - uses: actions/checkout@v2.3.4 + uses: actions/checkout@v3.5.0 with: fetch-depth: 0 - name: Install .NET SDK - uses: actions/setup-dotnet@v1.8.1 + uses: actions/setup-dotnet@v3.0.3 with: dotnet-version: 6.0.x - name: Build run: dotnet build LibGit2Sharp.sln --configuration Release - name: Upload packages - uses: actions/upload-artifact@v2.2.4 + uses: actions/upload-artifact@v3.1.2 with: name: NuGet packages path: bin/Packages/ @@ -44,16 +44,16 @@ jobs: fail-fast: false steps: - name: Checkout - uses: actions/checkout@v2.3.4 + uses: actions/checkout@v3.5.0 with: fetch-depth: 0 - name: Install .NET SDK - uses: actions/setup-dotnet@v1.8.1 + uses: actions/setup-dotnet@v3.0.3 with: dotnet-version: 6.0.x - name: Install .NET Core 3.1 runtime if: matrix.tfm == 'netcoreapp3.1' - uses: actions/setup-dotnet@v1.8.1 + uses: actions/setup-dotnet@v3.0.3 with: dotnet-version: 3.1.x - name: Run ${{ matrix.tfm }} tests @@ -86,7 +86,7 @@ jobs: fail-fast: false steps: - name: Checkout - uses: actions/checkout@v2.3.4 + uses: actions/checkout@v3.5.0 with: fetch-depth: 0 - name: Setup QEMU From b5bb4d5b168e325cd99539acc5143098a2dbf0e7 Mon Sep 17 00:00:00 2001 From: Brandon Ording Date: Fri, 7 Apr 2023 17:45:09 -0400 Subject: [PATCH 04/21] Add .NET 7 and remove .NET Core 3.1 --- .github/workflows/ci.yml | 21 +++++++++----------- LibGit2Sharp.Tests/BlobFixture.cs | 6 +++--- LibGit2Sharp.Tests/LibGit2Sharp.Tests.csproj | 2 +- LibGit2Sharp/LibGit2Sharp.csproj | 2 +- 4 files changed, 14 insertions(+), 17 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ac62110ec..878d9ecd1 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -21,7 +21,7 @@ jobs: - name: Install .NET SDK uses: actions/setup-dotnet@v3.0.3 with: - dotnet-version: 6.0.x + dotnet-version: 7.0.x - name: Build run: dotnet build LibGit2Sharp.sln --configuration Release - name: Upload packages @@ -36,8 +36,8 @@ jobs: strategy: matrix: arch: [ amd64 ] - os: [windows-2019, macos-10.15] - tfm: [ net472, netcoreapp3.1, net6.0 ] + os: [ windows-2019, macos-10.15 ] + tfm: [ net472, net6.0, net7.0 ] exclude: - os: macos-10.15 tfm: net472 @@ -50,12 +50,9 @@ jobs: - name: Install .NET SDK uses: actions/setup-dotnet@v3.0.3 with: - dotnet-version: 6.0.x - - name: Install .NET Core 3.1 runtime - if: matrix.tfm == 'netcoreapp3.1' - uses: actions/setup-dotnet@v3.0.3 - with: - dotnet-version: 3.1.x + dotnet-version: | + 7.0.x + 6.0.x - name: Run ${{ matrix.tfm }} tests run: dotnet test LibGit2Sharp.sln --configuration Release --framework ${{ matrix.tfm }} --logger "GitHubActions" /p:ExtraDefine=LEAKS_IDENTIFYING test-linux: @@ -66,7 +63,7 @@ jobs: arch: [ amd64 ] # arch: [ amd64, arm64 ] distro: [ alpine.3.12, alpine.3.13, alpine.3.14, centos.7, centos.8, debian.9, debian.10, debian.11, fedora.33, ubuntu.18.04, ubuntu.20.04 ] - sdk: [ '6.0', '3.1' ] + sdk: [ '6.0', '7.0' ] exclude: - arch: arm64 distro: alpine.3.12 @@ -81,8 +78,8 @@ jobs: include: - sdk: '6.0' tfm: net6.0 - - sdk: '3.1' - tfm: netcoreapp3.1 + - sdk: '7.0' + tfm: net7.0 fail-fast: false steps: - name: Checkout diff --git a/LibGit2Sharp.Tests/BlobFixture.cs b/LibGit2Sharp.Tests/BlobFixture.cs index ea35e59ef..314dea379 100644 --- a/LibGit2Sharp.Tests/BlobFixture.cs +++ b/LibGit2Sharp.Tests/BlobFixture.cs @@ -45,7 +45,7 @@ public void CanGetBlobAsFilteredText(string autocrlf, string expectedText) } } -#if NETFRAMEWORK || NETCOREAPP3_1 //UTF-7 is disabled in .NET 5+ +#if NETFRAMEWORK //UTF-7 is disabled in .NET 5+ [Theory] [InlineData("ascii", 4, "31 32 33 34")] [InlineData("utf-7", 4, "31 32 33 34")] @@ -239,11 +239,11 @@ public void CanTellIfABlobIsMissing() // Manually delete the objects directory to simulate a partial clone Directory.Delete(Path.Combine(repoPath, "objects", "a8"), true); - using (var repo = new Repository(repoPath)) + using (var repo = new Repository(repoPath)) { // Look up for the tree that reference the blob which is now missing var tree = repo.Lookup("fd093bff70906175335656e6ce6ae05783708765"); - var blob = (Blob) tree["README"].Target; + var blob = (Blob)tree["README"].Target; Assert.Equal("a8233120f6ad708f843d861ce2b7228ec4e3dec6", blob.Sha); Assert.NotNull(blob); diff --git a/LibGit2Sharp.Tests/LibGit2Sharp.Tests.csproj b/LibGit2Sharp.Tests/LibGit2Sharp.Tests.csproj index 25e652522..dc17e6d53 100644 --- a/LibGit2Sharp.Tests/LibGit2Sharp.Tests.csproj +++ b/LibGit2Sharp.Tests/LibGit2Sharp.Tests.csproj @@ -1,7 +1,7 @@  - net472;netcoreapp3.1;net6.0 + net472;net6.0;net7.0 diff --git a/LibGit2Sharp/LibGit2Sharp.csproj b/LibGit2Sharp/LibGit2Sharp.csproj index c81dd7093..bb6365716 100644 --- a/LibGit2Sharp/LibGit2Sharp.csproj +++ b/LibGit2Sharp/LibGit2Sharp.csproj @@ -1,7 +1,7 @@  - netstandard2.0;netcoreapp3.1 + netstandard2.0;net6.0 true LibGit2Sharp brings all the might and speed of libgit2, a native Git implementation, to the managed world of .NET LibGit2Sharp contributors From fbbfd7121b51a7dd1797cd34f38f9ed736a8b395 Mon Sep 17 00:00:00 2001 From: Brandon Ording Date: Sat, 8 Apr 2023 01:29:05 -0400 Subject: [PATCH 05/21] Fix warning --- LibGit2Sharp/ObjectDatabase.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/LibGit2Sharp/ObjectDatabase.cs b/LibGit2Sharp/ObjectDatabase.cs index 52aceb321..b48c72a99 100644 --- a/LibGit2Sharp/ObjectDatabase.cs +++ b/LibGit2Sharp/ObjectDatabase.cs @@ -315,10 +315,10 @@ private unsafe Blob CreateBlob(Stream stream, string hintpath, long? numberOfByt throw new EndOfStreamException("The stream ended unexpectedly"); } } - catch(Exception e) + catch (Exception) { writestream.free(writestream_ptr); - throw e; + throw; } ObjectId id = Proxy.git_blob_create_fromstream_commit(writestream_ptr); From 03cb81103f937385d004cadfeddf77a2470d74e1 Mon Sep 17 00:00:00 2001 From: Brandon Ording Date: Sat, 8 Apr 2023 01:34:36 -0400 Subject: [PATCH 06/21] Update testing packages --- LibGit2Sharp.Tests/LibGit2Sharp.Tests.csproj | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/LibGit2Sharp.Tests/LibGit2Sharp.Tests.csproj b/LibGit2Sharp.Tests/LibGit2Sharp.Tests.csproj index dc17e6d53..c5cbb5f24 100644 --- a/LibGit2Sharp.Tests/LibGit2Sharp.Tests.csproj +++ b/LibGit2Sharp.Tests/LibGit2Sharp.Tests.csproj @@ -11,12 +11,12 @@ - - - - - - + + + + + + From 81d501c16741a3d7b258750b1b45d56ed2ea9025 Mon Sep 17 00:00:00 2001 From: Brandon Ording Date: Sat, 8 Apr 2023 01:36:17 -0400 Subject: [PATCH 07/21] Update Microsoft.SourceLink.GitHub --- LibGit2Sharp/LibGit2Sharp.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/LibGit2Sharp/LibGit2Sharp.csproj b/LibGit2Sharp/LibGit2Sharp.csproj index bb6365716..597f37e31 100644 --- a/LibGit2Sharp/LibGit2Sharp.csproj +++ b/LibGit2Sharp/LibGit2Sharp.csproj @@ -31,7 +31,7 @@ - + From 079daef3aa558a1eb3a12f5b599c222f41077c93 Mon Sep 17 00:00:00 2001 From: Brandon Ording Date: Sat, 8 Apr 2023 01:52:39 -0400 Subject: [PATCH 08/21] Update workflow OSes --- .github/workflows/ci.yml | 24 +++++++++--------------- 1 file changed, 9 insertions(+), 15 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 878d9ecd1..cf961279d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -12,7 +12,7 @@ env: jobs: build: name: Build - runs-on: ubuntu-20.04 + runs-on: ubuntu-22.04 steps: - name: Checkout uses: actions/checkout@v3.5.0 @@ -36,10 +36,10 @@ jobs: strategy: matrix: arch: [ amd64 ] - os: [ windows-2019, macos-10.15 ] + os: [ windows-2019, macos-11 ] tfm: [ net472, net6.0, net7.0 ] exclude: - - os: macos-10.15 + - os: macos-11 tfm: net472 fail-fast: false steps: @@ -57,24 +57,18 @@ jobs: run: dotnet test LibGit2Sharp.sln --configuration Release --framework ${{ matrix.tfm }} --logger "GitHubActions" /p:ExtraDefine=LEAKS_IDENTIFYING test-linux: name: Test / ${{ matrix.distro }} / ${{ matrix.arch }} / ${{ matrix.tfm }} - runs-on: ubuntu-20.04 + runs-on: ubuntu-22.04 strategy: matrix: arch: [ amd64 ] # arch: [ amd64, arm64 ] - distro: [ alpine.3.12, alpine.3.13, alpine.3.14, centos.7, centos.8, debian.9, debian.10, debian.11, fedora.33, ubuntu.18.04, ubuntu.20.04 ] + distro: [ alpine.3.13, alpine.3.14, alpine.3.15, alpine.3.16, alpine.3.17, centos.7, centos.stream.8, debian.10, debian.11, fedora.36, ubuntu.18.04, ubuntu.20.04, ubuntu.22.04 ] sdk: [ '6.0', '7.0' ] exclude: - - arch: arm64 - distro: alpine.3.12 - - arch: arm64 - distro: alpine.3.13 - sdk: '3.1' - - arch: arm64 - distro: alpine.3.14 - sdk: '3.1' - - arch: arm64 - distro: centos.7 + - distro: alpine.3.13 + sdk: '7.0' + - distro: alpine.3.14 + sdk: '7.0' include: - sdk: '6.0' tfm: net6.0 From f1789346c9856f4d93718f605d62d85576a7af5e Mon Sep 17 00:00:00 2001 From: Brandon Ording Date: Sat, 8 Apr 2023 12:42:43 -0400 Subject: [PATCH 09/21] Remove netstandard2.0 and add net472 --- LibGit2Sharp/Core/NativeMethods.cs | 2 +- LibGit2Sharp/LibGit2Sharp.csproj | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/LibGit2Sharp/Core/NativeMethods.cs b/LibGit2Sharp/Core/NativeMethods.cs index f5d45f3cf..e20d755ba 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 NETFRAMEWORK private static bool TryUseNativeLibrary() => false; #else private static bool TryUseNativeLibrary() diff --git a/LibGit2Sharp/LibGit2Sharp.csproj b/LibGit2Sharp/LibGit2Sharp.csproj index 597f37e31..0b88a3af5 100644 --- a/LibGit2Sharp/LibGit2Sharp.csproj +++ b/LibGit2Sharp/LibGit2Sharp.csproj @@ -1,7 +1,7 @@  - netstandard2.0;net6.0 + net472;net6.0 true LibGit2Sharp brings all the might and speed of libgit2, a native Git implementation, to the managed world of .NET LibGit2Sharp contributors From 48460d087d6622159f929f9aa7476d182ca7078b Mon Sep 17 00:00:00 2001 From: Brandon Ording Date: Sat, 8 Apr 2023 12:46:16 -0400 Subject: [PATCH 10/21] Fix Assembly CodeBase warning --- LibGit2Sharp/GlobalSettings.cs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/LibGit2Sharp/GlobalSettings.cs b/LibGit2Sharp/GlobalSettings.cs index f8db7401a..31cba0965 100644 --- a/LibGit2Sharp/GlobalSettings.cs +++ b/LibGit2Sharp/GlobalSettings.cs @@ -20,7 +20,7 @@ public static class GlobalSettings private static string nativeLibraryPath; private static bool nativeLibraryPathLocked; - private static string nativeLibraryDefaultPath; + private static readonly string nativeLibraryDefaultPath = null; static GlobalSettings() { @@ -29,19 +29,18 @@ static GlobalSettings() nativeLibraryPathAllowed = netFX || netCore; +#if NETFRAMEWORK if (netFX) { // For .NET Framework apps the dependencies are deployed to lib/win32/{architecture} directory nativeLibraryDefaultPath = Path.Combine(GetExecutingAssemblyDirectory(), "lib", "win32", Platform.ProcessorArchitecture); } - else - { - nativeLibraryDefaultPath = null; - } +#endif registeredFilters = new Dictionary(); } +#if NETFRAMEWORK private static string GetExecutingAssemblyDirectory() { // Assembly.CodeBase is not actually a correctly formatted @@ -66,6 +65,7 @@ private static string GetExecutingAssemblyDirectory() managedPath = Path.GetDirectoryName(managedPath); return managedPath; } +#endif /// /// Returns information related to the current LibGit2Sharp From c157b6a5a72ae64da5856fa5d24f5b7847d7793d Mon Sep 17 00:00:00 2001 From: Brandon Ording Date: Sat, 8 Apr 2023 13:15:21 -0400 Subject: [PATCH 11/21] Update RemoteRedirectMode to match git_remote_redirect_t --- LibGit2Sharp/Core/GitFetchOptions.cs | 2 +- LibGit2Sharp/Core/GitPushOptions.cs | 2 +- LibGit2Sharp/RemoteRedirectMode.cs | 8 ++++---- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/LibGit2Sharp/Core/GitFetchOptions.cs b/LibGit2Sharp/Core/GitFetchOptions.cs index bdf8aa585..d82e2f219 100644 --- a/LibGit2Sharp/Core/GitFetchOptions.cs +++ b/LibGit2Sharp/Core/GitFetchOptions.cs @@ -11,7 +11,7 @@ internal class GitFetchOptions public bool UpdateFetchHead = true; public TagFetchMode download_tags; public GitProxyOptions ProxyOptions; - public RemoteRedirectMode FollowRedirects = RemoteRedirectMode.Auto; + public RemoteRedirectMode FollowRedirects = RemoteRedirectMode.Initial; public GitStrArrayManaged CustomHeaders; } } diff --git a/LibGit2Sharp/Core/GitPushOptions.cs b/LibGit2Sharp/Core/GitPushOptions.cs index 8c98ce9cc..ce1a58f7c 100644 --- a/LibGit2Sharp/Core/GitPushOptions.cs +++ b/LibGit2Sharp/Core/GitPushOptions.cs @@ -9,7 +9,7 @@ internal class GitPushOptions public int PackbuilderDegreeOfParallelism; public GitRemoteCallbacks RemoteCallbacks; public GitProxyOptions ProxyOptions; - public RemoteRedirectMode FollowRedirects = RemoteRedirectMode.Auto; + public RemoteRedirectMode FollowRedirects = RemoteRedirectMode.Initial; public GitStrArrayManaged CustomHeaders; } } diff --git a/LibGit2Sharp/RemoteRedirectMode.cs b/LibGit2Sharp/RemoteRedirectMode.cs index 08866e68a..029208857 100644 --- a/LibGit2Sharp/RemoteRedirectMode.cs +++ b/LibGit2Sharp/RemoteRedirectMode.cs @@ -1,7 +1,7 @@ namespace LibGit2Sharp { /// - /// Remote redirection settings; wehther redirects to another + /// Remote redirection settings; whether redirects to another /// host are permitted. By default, git will follow a redirect /// on the initial request (`/info/refs`) but not subsequent /// requests. @@ -12,17 +12,17 @@ public enum RemoteRedirectMode /// Do not follow any off-site redirects at any stage of /// the fetch or push. /// - None = 0, // GIT_REMOTE_REDIRECT_NONE + None = 1 << 0, // GIT_REMOTE_REDIRECT_NONE /// /// Allow off-site redirects only upon the initial /// request. This is the default. /// - Auto, // GIT_REMOTE_REDIRECT_INITIAL + Initial = 1 << 1, // GIT_REMOTE_REDIRECT_INITIAL /// /// Allow redirects at any stage in the fetch or push. /// - All // GIT_REMOTE_REDIRECT_ALL + All = 1 << 2 // GIT_REMOTE_REDIRECT_ALL } } From a7ded296a01358fda726eb8ac27039cc5d2f0433 Mon Sep 17 00:00:00 2001 From: Mark Adamson <3154635+mungojam@users.noreply.github.com> Date: Sat, 8 Apr 2023 18:40:50 +0100 Subject: [PATCH 12/21] Add NuGet package badge (#1980) --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 8ed3fb4d2..3aafdceb1 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,7 @@ # LibGit2Sharp -[![CI](https://github.com/libgit2/libgit2sharp/actions/workflows/ci.yml/badge.svg)](https://github.com/libgit2/libgit2sharp/actions/workflows/ci.yml) +[![CI](https://github.com/libgit2/libgit2sharp/actions/workflows/ci.yml/badge.svg)](https://github.com/libgit2/libgit2sharp/actions/workflows/ci.yml) +[![NuGet version (LibGit2Sharp)](https://img.shields.io/nuget/v/LibGit2Sharp.svg)](https://www.nuget.org/packages/LibGit2Sharp/) **LibGit2Sharp brings all the might and speed of [libgit2](http://libgit2.github.com/), a native Git implementation, to the managed world of .NET** From 1d64999130c392e553b827246f6963c779bf668f Mon Sep 17 00:00:00 2001 From: Brandon Ording Date: Sat, 8 Apr 2023 21:33:05 -0400 Subject: [PATCH 13/21] Switch to MinVer for versioning --- LibGit2Sharp.sln | 5 ++-- LibGit2Sharp/LibGit2Sharp.csproj | 8 +++--- LibGit2Sharp/Version.cs | 12 +++++++-- Targets/CodeGenerator.targets | 37 ++++++++++----------------- Targets/GenerateNativeDllName.targets | 5 +--- version.json | 13 ---------- 6 files changed, 31 insertions(+), 49 deletions(-) delete mode 100644 version.json diff --git a/LibGit2Sharp.sln b/LibGit2Sharp.sln index a81b0ce37..e99eec26f 100644 --- a/LibGit2Sharp.sln +++ b/LibGit2Sharp.sln @@ -1,6 +1,6 @@ Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 16 -VisualStudioVersion = 16.0.28803.202 +# Visual Studio Version 17 +VisualStudioVersion = 17.5.33516.290 MinimumVisualStudioVersion = 10.0.40219.1 Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LibGit2Sharp", "LibGit2Sharp\LibGit2Sharp.csproj", "{EE6ED99F-CB12-4683-B055-D28FC7357A34}" EndProject @@ -13,7 +13,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Directory.Build.props = Directory.Build.props Targets\GenerateNativeDllName.targets = Targets\GenerateNativeDllName.targets nuget.config = nuget.config - version.json = version.json EndProjectSection EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NativeLibraryLoadTestApp.x86", "NativeLibraryLoadTestApp\x86\NativeLibraryLoadTestApp.x86.csproj", "{86453D2C-4953-4DF4-B12A-ADE579608BAA}" diff --git a/LibGit2Sharp/LibGit2Sharp.csproj b/LibGit2Sharp/LibGit2Sharp.csproj index 0b88a3af5..6aa70519c 100644 --- a/LibGit2Sharp/LibGit2Sharp.csproj +++ b/LibGit2Sharp/LibGit2Sharp.csproj @@ -17,6 +17,8 @@ square-logo.png App_Readme/LICENSE.md true + preview.0 + libgit2-$(libgit2_hash.Substring(0,7)) @@ -32,15 +34,15 @@ - + - + - https://github.com/libgit2/libgit2sharp/blob/$(GitCommitIdShort)/CHANGES.md#libgit2sharp-changes + https://github.com/libgit2/libgit2sharp/blob/$(SourceRevisionId)/CHANGES.md diff --git a/LibGit2Sharp/Version.cs b/LibGit2Sharp/Version.cs index 3795382a3..2c21ccad2 100644 --- a/LibGit2Sharp/Version.cs +++ b/LibGit2Sharp/Version.cs @@ -1,4 +1,5 @@ using System.Globalization; +using System.Reflection; using LibGit2Sharp.Core; namespace LibGit2Sharp @@ -22,7 +23,14 @@ internal static Version Build() /// /// Returns version of the LibGit2Sharp library. /// - public virtual string InformationalVersion => ThisAssembly.AssemblyInformationalVersion; + public virtual string InformationalVersion + { + get + { + var attribute = Assembly.GetExecutingAssembly().GetCustomAttribute(); + return attribute.InformationalVersion; + } + } /// /// Returns all the optional features that were compiled into @@ -55,7 +63,7 @@ private string RetrieveAbbrevShaFrom(string sha) /// /// /// The format of the version number is as follows: - /// Major.Minor.Patch[-previewTag]+{LibGit2Sharp_abbrev_hash}.libgit2-{libgit2_abbrev_hash} (x86|x64 - features) + /// Major.Minor.Patch[-previewTag]+libgit2-{libgit2_abbrev_hash}.{LibGit2Sharp_hash} (arch - features) /// /// public override string ToString() diff --git a/Targets/CodeGenerator.targets b/Targets/CodeGenerator.targets index 249cd4f38..16eb8f05b 100644 --- a/Targets/CodeGenerator.targets +++ b/Targets/CodeGenerator.targets @@ -1,22 +1,24 @@  - - $(MSBuildAllProjects);$(MSBuildThisFileFullPath) - - + $(IntermediateOutputPath)SourceRevisionId.txt $(IntermediateOutputPath)UniqueIdentifier.g.cs $(IntermediateOutputPath)AssemblyCommitIds.g.cs + + + + + + - - + - $([System.Guid]::NewGuid()) - $(GitCommitId) + $(SourceRevisionId) + $([System.Guid]::NewGuid()) namespace LibGit2Sharp.Core { @@ -34,24 +36,12 @@ - - - - - - - - - - - - - + - unknown - $(GitCommitId) + $(SourceRevisionId) + unknown namespace LibGit2Sharp { @@ -70,7 +60,6 @@ - diff --git a/Targets/GenerateNativeDllName.targets b/Targets/GenerateNativeDllName.targets index 244b707b4..c74dcd31e 100644 --- a/Targets/GenerateNativeDllName.targets +++ b/Targets/GenerateNativeDllName.targets @@ -1,9 +1,5 @@  - - $(MSBuildAllProjects);$(MSBuildThisFileFullPath) - - $(IntermediateOutputPath)NativeDllName.g.cs @@ -30,4 +26,5 @@ + diff --git a/version.json b/version.json deleted file mode 100644 index b0cb8c411..000000000 --- a/version.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "$schema": "https://raw.githubusercontent.com/AArnott/Nerdbank.GitVersioning/master/src/NerdBank.GitVersioning/version.schema.json", - "version": "0.27.0-preview.{height}", - "publicReleaseRefSpec": [ - "^refs/heads/master$", // we release out of master - "^refs/heads/maint/v\\d+(?:\\.\\d+)?$" // and maint/vNN branches - ], - "cloudBuild": { - "buildNumber": { - "enabled": true - } - } -} From 2da1e0eab8bd210dca2a950d90809ff103d59980 Mon Sep 17 00:00:00 2001 From: Brandon Ording Date: Sat, 8 Apr 2023 22:09:42 -0400 Subject: [PATCH 14/21] Update version test --- LibGit2Sharp.Tests/GlobalSettingsFixture.cs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/LibGit2Sharp.Tests/GlobalSettingsFixture.cs b/LibGit2Sharp.Tests/GlobalSettingsFixture.cs index e067fd192..cd237663e 100644 --- a/LibGit2Sharp.Tests/GlobalSettingsFixture.cs +++ b/LibGit2Sharp.Tests/GlobalSettingsFixture.cs @@ -23,25 +23,25 @@ public void CanGetMinimumCompiledInFeatures() public void CanRetrieveValidVersionString() { // Version string format is: - // Major.Minor.Patch[-previewTag]+{LibGit2Sharp_abbrev_hash}.libgit2-{libgit2_abbrev_hash} (x86|x64 - features) + // Major.Minor.Patch[-previewTag]+libgit2-{libgit2_abbrev_hash}.{LibGit2Sharp_hash} (arch - features) // Example output: - // "0.25.0-preview.52+871d13a67f.libgit2-15e1193 (x86 - Threads, Https)" + // "0.27.0-preview.0.1896+libgit2-c058aa8.c1ac3ed74487da5fac24cf1e48dc8ea71e917b75 (x64 - Threads, Https, NSec)" string versionInfo = GlobalSettings.Version.ToString(); // The GlobalSettings.Version returned string should contain : // version: '0.25.0[-previewTag]' LibGit2Sharp version number. - // git2SharpHash: '871d13a67f' LibGit2Sharp hash. + // git2SharpHash: 'c1ac3ed74487da5fac24cf1e48dc8ea71e917b75' LibGit2Sharp hash. // arch: 'x86' or 'x64' libgit2 target. // git2Features: 'Threads, Ssh' libgit2 features compiled with. - string regex = @"^(?\d+\.\d+\.\d+(-[\w\-\.]+)?\+((?[a-f0-9]{10})\.)?libgit2-[a-f0-9]{7}) \((?\w+) - (?(?:\w*(?:, )*\w+)*)\)$"; + string regex = @"^(?\d+\.\d+\.\d+(-[\w\-\.]+)?)\+libgit2-[a-f0-9]{7}\.((?[a-f0-9]{40}))? \((?\w+) - (?(?:\w*(?:, )*\w+)*)\)$"; Assert.NotNull(versionInfo); Match regexResult = Regex.Match(versionInfo, regex); Assert.True(regexResult.Success, "The following version string format is enforced:" + - "Major.Minor.Patch[-previewTag]+{LibGit2Sharp_abbrev_hash}.libgit2-{libgit2_abbrev_hash} (x86|x64 - features). " + + "Major.Minor.Patch[-previewTag]+libgit2-{libgit2_abbrev_hash}.{LibGit2Sharp_hash} (arch - features). " + "But found \"" + versionInfo + "\" instead."); } From 8e1fe56a427ad30129f2e1fbe7fd29d044c714bd Mon Sep 17 00:00:00 2001 From: Brandon Ording Date: Sun, 9 Apr 2023 02:10:38 -0400 Subject: [PATCH 15/21] Mark repo safe to fix MinVer warning --- .github/workflows/ci.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index cf961279d..f44285812 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -85,5 +85,7 @@ jobs: run: docker run --rm --privileged multiarch/qemu-user-static:register --reset - name: Run ${{ matrix.tfm }} tests run: | + git_command="git config --global --add safe.directory /app" test_command="dotnet test LibGit2Sharp.sln --configuration Release -p:TargetFrameworks=${{ matrix.tfm }} --logger "GitHubActions" -p:ExtraDefine=LEAKS_IDENTIFYING" - docker run -t --rm --platform linux/${{ matrix.arch }} -v "$PWD:/app" gittools/build-images:${{ matrix.distro }}-sdk-${{ matrix.sdk }} sh -c "$test_command" + docker run -t --rm --platform linux/${{ matrix.arch }} -v "$PWD:/app" gittools/build-images:${{ matrix.distro }}-sdk-${{ matrix.sdk }} sh -c "$git_command && $test_command" + From 9552731c51aff4e0a76dd6c2ac87ba90cf0c0aff Mon Sep 17 00:00:00 2001 From: Brandon Ording Date: Mon, 10 Apr 2023 20:19:09 -0400 Subject: [PATCH 16/21] Add v0.27 changes --- CHANGES.md | 31 ++++++++++++++++++++++--------- 1 file changed, 22 insertions(+), 9 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 78bd537f6..c902a8640 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,14 +1,27 @@ # LibGit2Sharp Changes -**LibGit2Sharp brings all the might and speed of libgit2, a native Git implementation, to the managed world of .Net and Mono.** - - - Source code: - - NuGet package: - - Issue tracker: - - @libgit2sharp: - - CI servers: - - Windows (x86/amd64): - - Linux/Mac OS X: +## v0.27 - ([diff](https://github.com/libgit2/libgit2sharp/compare/v0.26..0.27.0)) + +### Changes +- LibGit2Sharp now targets .NET Framework 4.7.2 and .NET 6. +- This release includes [libgit2 v1.6.3](https://github.com/libgit2/libgit2/releases/tag/v1.6.3). +- Changes to the native binaries let LibGit2Sharp work on all [.NET 6 supported OS versions and architectures](https://github.com/dotnet/core/blob/main/release-notes/6.0/supported-os.md). +- `GlobalSetings.NativeLibraryPath` used to automatically append architecture to the path when running on .NET Framework. This behavior has been removed to make it consistent. [#1918](https://github.com/libgit2/libgit2sharp/pull/1918) + +### Additions +- Add support for adding and clearing multi-valued configuration [#1720](https://github.com/libgit2/libgit2sharp/pull/1720) +- added lines and deleted lines in content changes [#1790](https://github.com/libgit2/libgit2sharp/pull/1790) +- Set / get supported extensions [#1908](https://github.com/libgit2/libgit2sharp/pull/1908) +- Simplify dealing with missing git objects [#1909](https://github.com/libgit2/libgit2sharp/pull/1909) +- Throw NotFoundException if trees are missing when computing diff [#1936](https://github.com/libgit2/libgit2sharp/pull/1936) + +### Fixes +- Adjust GitStatusOptions to match structure of native libgit2 [#1884](https://github.com/libgit2/libgit2sharp/pull/1884) +- Update git_worktree_add_options struct to include ref pointer [#1890](https://github.com/libgit2/libgit2sharp/pull/1890) +- Fix git_remote_connect not throwing on non-zero result [#1913](https://github.com/libgit2/libgit2sharp/pull/1913) +- Fix incorrect information in exceptions [#1919](https://github.com/libgit2/libgit2sharp/pull/1919) +- Checkout branch looks to remote tracking branches as fallback [#1820](https://github.com/libgit2/libgit2sharp/pull/1820) +- Fixed calling into native libgit2 on osx-arm64 [#1955](https://github.com/libgit2/libgit2sharp/pull/1955) ## v0.26 - ([diff](https://github.com/libgit2/libgit2sharp/compare/v0.25..v0.26)) From 10cd32c43a73995e6c61e091868d9722e8060ff3 Mon Sep 17 00:00:00 2001 From: Brandon Ording Date: Mon, 10 Apr 2023 21:04:31 -0400 Subject: [PATCH 17/21] Add PackageReadmeFile property --- LibGit2Sharp/LibGit2Sharp.csproj | 1 + 1 file changed, 1 insertion(+) diff --git a/LibGit2Sharp/LibGit2Sharp.csproj b/LibGit2Sharp/LibGit2Sharp.csproj index 6aa70519c..db0d2b29f 100644 --- a/LibGit2Sharp/LibGit2Sharp.csproj +++ b/LibGit2Sharp/LibGit2Sharp.csproj @@ -15,6 +15,7 @@ true ..\libgit2sharp.snk square-logo.png + App_Readme/README.md App_Readme/LICENSE.md true preview.0 From 4dc402a36e795b956475fbde41d50555dfdde58b Mon Sep 17 00:00:00 2001 From: Brandon Ording Date: Tue, 11 Apr 2023 13:07:20 -0400 Subject: [PATCH 18/21] Fix AssemblyVersion and PackageVersion --- LibGit2Sharp/LibGit2Sharp.csproj | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/LibGit2Sharp/LibGit2Sharp.csproj b/LibGit2Sharp/LibGit2Sharp.csproj index db0d2b29f..abab84c8a 100644 --- a/LibGit2Sharp/LibGit2Sharp.csproj +++ b/LibGit2Sharp/LibGit2Sharp.csproj @@ -47,4 +47,12 @@ + + + $(MinVerMajor).$(MinVerMinor).0.0 + $(MinVerMajor).$(MinVerMinor).$(MinVerPatch) + $(PackageVersion)-$(MinVerPreRelease) + + + From 82c190bb997b5e1a003d47b51f662150332697ae Mon Sep 17 00:00:00 2001 From: Brandon Ording Date: Tue, 11 Apr 2023 13:21:18 -0400 Subject: [PATCH 19/21] Add fix to Changes doc --- CHANGES.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CHANGES.md b/CHANGES.md index c902a8640..6341b4438 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,5 +1,10 @@ # LibGit2Sharp Changes +## v0.27.1 - ([diff](https://github.com/libgit2/libgit2sharp/compare/0.27.0..0.27.1)) + +### Fixes + - AssemblyVersion of v0.27.0 is `0.0.0.0`, which is lower than the AssemblyVersion of the v0.26.x releases. [#2030](https://github.com/libgit2/libgit2sharp/pull/2030) + ## v0.27 - ([diff](https://github.com/libgit2/libgit2sharp/compare/v0.26..0.27.0)) ### Changes From 2419633cf4673b6a7d36af9cf47f25a84587acdd Mon Sep 17 00:00:00 2001 From: Brandon Ording Date: Wed, 12 Apr 2023 12:45:06 -0400 Subject: [PATCH 20/21] Update LibGit2Sharp.NativeBinaries to 2.0.320 --- LibGit2Sharp/LibGit2Sharp.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/LibGit2Sharp/LibGit2Sharp.csproj b/LibGit2Sharp/LibGit2Sharp.csproj index abab84c8a..f690c9107 100644 --- a/LibGit2Sharp/LibGit2Sharp.csproj +++ b/LibGit2Sharp/LibGit2Sharp.csproj @@ -33,7 +33,7 @@ - + From ce3be35fb51968e007b6a9f3478bb5078ba3c4c3 Mon Sep 17 00:00:00 2001 From: Brandon Ording Date: Wed, 12 Apr 2023 15:05:26 -0400 Subject: [PATCH 21/21] Update CHANGES doc --- CHANGES.md | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/CHANGES.md b/CHANGES.md index 6341b4438..a3a74c0d5 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,9 +1,17 @@ # LibGit2Sharp Changes +## v0.27.2 - ([diff](https://github.com/libgit2/libgit2sharp/compare/0.27.1..0.27.2)) + +### Changes +- This release includes [libgit2 v1.6.4](https://github.com/libgit2/libgit2/releases/tag/v1.6.4). + +### Fixes +- Can't access GIT config (Repository.Config) since v0.27.0 [#2031](https://github.com/libgit2/libgit2sharp/issues/2031) + ## v0.27.1 - ([diff](https://github.com/libgit2/libgit2sharp/compare/0.27.0..0.27.1)) ### Fixes - - AssemblyVersion of v0.27.0 is `0.0.0.0`, which is lower than the AssemblyVersion of the v0.26.x releases. [#2030](https://github.com/libgit2/libgit2sharp/pull/2030) +- AssemblyVersion of v0.27.0 is `0.0.0.0`, which is lower than the AssemblyVersion of the v0.26.x releases. [#2030](https://github.com/libgit2/libgit2sharp/pull/2030) ## v0.27 - ([diff](https://github.com/libgit2/libgit2sharp/compare/v0.26..0.27.0))