Skip to content

Commit 9b2bac1

Browse files
authored
Update libgit2 native binaries (#26)
1 parent 3efac0b commit 9b2bac1

16 files changed

Lines changed: 179 additions & 131 deletions

.github/workflows/ci.yml

Lines changed: 129 additions & 116 deletions
Original file line numberDiff line numberDiff line change
@@ -1,120 +1,133 @@
11
name: CI
22
on:
3-
push:
4-
branches: [master, release-*]
5-
tags:
6-
- '[0-9]+.[0-9]+.[0-9]+'
7-
- '[0-9]+.[0-9]+.[0-9]+-*'
8-
pull_request:
9-
workflow_dispatch:
3+
push:
4+
branches: [master, release-*]
5+
tags:
6+
- "[0-9]+.[0-9]+.[0-9]+"
7+
- "[0-9]+.[0-9]+.[0-9]+-*"
8+
pull_request:
9+
workflow_dispatch:
1010
env:
11-
DOTNET_NOLOGO: true
11+
DOTNET_NOLOGO: true
1212
jobs:
13-
build:
14-
name: Build
15-
runs-on: ubuntu-22.04
16-
steps:
17-
- name: Checkout
18-
uses: actions/checkout@v4.1.2
19-
with:
20-
fetch-depth: 0
21-
- name: Install .NET SDK
22-
uses: actions/setup-dotnet@v4.0.0
23-
with:
24-
dotnet-version: 9.0.x
25-
- name: Build
26-
run: dotnet build LibGit2Sharp.sln --configuration Release
27-
- name: Upload packages
28-
uses: actions/upload-artifact@v4.3.1
29-
with:
30-
name: NuGet packages
31-
path: artifacts/package/
32-
retention-days: 7
33-
- name: Verify trimming compatibility
34-
run: dotnet publish TrimmingTestApp
35-
36-
test:
37-
name: Test / ${{ matrix.os }} / ${{ matrix.arch }} / ${{ matrix.tfm }}
38-
runs-on: ${{ matrix.os }}
39-
strategy:
40-
matrix:
41-
arch: [ x64 ]
42-
os: [ windows-2022, macos-14 ]
43-
tfm: [ net472, net8.0, net9.0 ]
44-
exclude:
45-
- os: macos-14
46-
tfm: net472
47-
include:
48-
- arch: arm64
49-
os: macos-14
50-
tfm: net8.0
51-
- arch: arm64
52-
os: macos-14
53-
tfm: net9.0
54-
fail-fast: false
55-
steps:
56-
- name: Checkout
57-
uses: actions/checkout@v4.1.2
58-
with:
59-
fetch-depth: 0
60-
- name: Install .NET SDK
61-
uses: actions/setup-dotnet@v4.0.0
62-
with:
63-
dotnet-version: |
64-
9.0.x
65-
8.0.x
66-
- name: Run ${{ matrix.tfm }} tests
67-
run: dotnet test LibGit2Sharp.sln --configuration Release --framework ${{ matrix.tfm }} --logger "GitHubActions" /p:ExtraDefine=LEAKS_IDENTIFYING
68-
test-linux:
69-
name: Test / ${{ matrix.distro }} / ${{ matrix.arch }} / ${{ matrix.tfm }}
70-
runs-on: ${{ matrix.runnerImage }}
71-
strategy:
72-
matrix:
73-
arch: [ amd64, arm64 ]
74-
distro: [ alpine.3.17, alpine.3.18, alpine.3.19, alpine.3.20, centos.stream.9, debian.12, fedora.40, ubuntu.20.04, ubuntu.22.04, ubuntu.24.04 ]
75-
sdk: [ '8.0', '9.0' ]
76-
exclude:
77-
- distro: alpine.3.17
78-
sdk: '9.0'
79-
- distro: alpine.3.18
80-
sdk: '9.0'
81-
- distro: alpine.3.19
82-
sdk: '9.0'
83-
include:
84-
- sdk: '8.0'
85-
tfm: net8.0
86-
- sdk: '9.0'
87-
tfm: net9.0
88-
- arch: amd64
89-
runnerImage: ubuntu-22.04
90-
- arch: arm64
91-
runnerImage: ubuntu-22.04-arm
92-
fail-fast: false
93-
steps:
94-
- name: Checkout
95-
uses: actions/checkout@v4.1.2
96-
with:
97-
fetch-depth: 0
98-
- name: Run ${{ matrix.tfm }} tests
99-
run: |
100-
git_command="git config --global --add safe.directory /app"
101-
test_command="dotnet test LibGit2Sharp.sln --configuration Release -p:TargetFrameworks=${{ matrix.tfm }} --logger "GitHubActions" -p:ExtraDefine=LEAKS_IDENTIFYING"
102-
docker run -t --rm --platform linux/${{ matrix.arch }} -v "$PWD:/app" -e OPENSSL_ENABLE_SHA1_SIGNATURES=1 gittools/build-images:${{ matrix.distro }}-sdk-${{ matrix.sdk }} sh -c "$git_command && $test_command"
103-
104-
nuget-push:
105-
name: Octopus NuGet Push
106-
needs: [build, test, test-linux]
107-
# && github.ref == 'refs/heads/octopus/master'
108-
if: github.actor != 'dependabot[bot]' && github.actor != 'dependabot-preview[bot]' && github.event_name != 'schedule'
109-
runs-on: ubuntu-22.04
110-
steps:
111-
- uses: actions/download-artifact@v4
112-
with:
113-
path: staging
114-
- name: Push package to feed 🐙
115-
id: push-feed
116-
shell: bash
117-
env:
118-
FEED_API_KEY: ${{ secrets.FEED_API_KEY }}
119-
FEED_SOURCE: ${{ secrets.FEED_SOURCE }}
120-
run: dotnet nuget push staging/**/*.nupkg --api-key "$FEED_API_KEY" --source "$FEED_SOURCE"
13+
build:
14+
name: Build
15+
runs-on: ubuntu-22.04
16+
steps:
17+
- name: Checkout
18+
uses: actions/checkout@v6
19+
with:
20+
fetch-depth: 0
21+
- name: Install .NET SDK
22+
uses: actions/setup-dotnet@v5
23+
with:
24+
dotnet-version: 9.0.x
25+
- name: Compute version suffix for branch builds
26+
if: ${{ !startsWith(github.ref, 'refs/tags/') }}
27+
id: version
28+
run: |
29+
# Sanitize branch name: lowercase, replace non-alphanumeric with hyphen, trim to 20 chars
30+
BRANCH="${GITHUB_HEAD_REF:-${GITHUB_REF_NAME}}"
31+
SAFE_BRANCH=$(echo "$BRANCH" | tr '[:upper:]' '[:lower:]' | sed 's/[^a-z0-9]/-/g' | sed 's/--*/-/g' | sed 's/^-//' | sed 's/-$//' | cut -c1-20)
32+
echo "override=${SAFE_BRANCH}.${{ github.run_number }}" >> "$GITHUB_OUTPUT"
33+
- name: Build
34+
run: dotnet build LibGit2Sharp.sln --configuration Release ${{ steps.version.outputs.override && format('/p:MinVerDefaultPreReleaseIdentifiers="{0}"', steps.version.outputs.override) || '' }}
35+
- name: Upload packages
36+
uses: actions/upload-artifact@v7
37+
with:
38+
name: NuGet packages
39+
path: artifacts/package/
40+
retention-days: 7
41+
- name: Verify trimming compatibility
42+
run: dotnet publish TrimmingTestApp
43+
44+
test:
45+
name: Test / ${{ matrix.os }} / ${{ matrix.arch }} / ${{ matrix.tfm }}
46+
runs-on: ${{ matrix.os }}
47+
strategy:
48+
matrix:
49+
arch: [x64]
50+
os: [windows-2022, macos-14]
51+
tfm: [net472, net8.0, net9.0]
52+
exclude:
53+
- os: macos-14
54+
tfm: net472
55+
include:
56+
- arch: arm64
57+
os: macos-14
58+
tfm: net8.0
59+
- arch: arm64
60+
os: macos-14
61+
tfm: net9.0
62+
fail-fast: false
63+
steps:
64+
- name: Checkout
65+
uses: actions/checkout@v6
66+
with:
67+
fetch-depth: 0
68+
- name: Install .NET SDK
69+
uses: actions/setup-dotnet@v5
70+
with:
71+
dotnet-version: |
72+
9.0.x
73+
8.0.x
74+
- name: Run ${{ matrix.tfm }} tests
75+
run: dotnet test LibGit2Sharp.sln --configuration Release --framework ${{ matrix.tfm }} --logger "GitHubActions" /p:ExtraDefine=LEAKS_IDENTIFYING
76+
test-linux:
77+
name: Test / ${{ matrix.distro }} / ${{ matrix.arch }} / ${{ matrix.tfm }}
78+
runs-on: ${{ matrix.runnerImage }}
79+
strategy:
80+
matrix:
81+
arch: [amd64, arm64]
82+
distro:
83+
[
84+
alpine.3.20,
85+
alpine.3.21,
86+
alpine.3.22,
87+
centos.stream.9,
88+
debian.12,
89+
fedora.41,
90+
fedora.42,
91+
ubuntu.22.04,
92+
ubuntu.24.04,
93+
]
94+
sdk: ["8.0", "9.0"]
95+
include:
96+
- sdk: "8.0"
97+
tfm: net8.0
98+
- sdk: "9.0"
99+
tfm: net9.0
100+
- arch: amd64
101+
runnerImage: ubuntu-22.04
102+
- arch: arm64
103+
runnerImage: ubuntu-22.04-arm
104+
fail-fast: false
105+
steps:
106+
- name: Checkout
107+
uses: actions/checkout@v6
108+
with:
109+
fetch-depth: 0
110+
- name: Run ${{ matrix.tfm }} tests
111+
run: |
112+
git_command="git config --global --add safe.directory /app"
113+
test_command="dotnet test LibGit2Sharp.sln --configuration Release -p:TargetFrameworks=${{ matrix.tfm }} --logger "GitHubActions" -p:ExtraDefine=LEAKS_IDENTIFYING"
114+
docker run -t --rm --platform linux/${{ matrix.arch }} -v "$PWD:/app" -w /app -e OPENSSL_ENABLE_SHA1_SIGNATURES=1 gittools/build-images:${{ matrix.distro }}-sdk-${{ matrix.sdk }} sh -c "$git_command && $test_command"
115+
116+
nuget-push:
117+
name: Octopus NuGet Push
118+
needs: [build, test, test-linux]
119+
# && github.ref == 'refs/heads/octopus/master'
120+
if: github.actor != 'dependabot[bot]' && github.actor != 'dependabot-preview[bot]' && github.event_name != 'schedule'
121+
runs-on: ubuntu-22.04
122+
steps:
123+
- uses: actions/download-artifact@v8
124+
125+
with:
126+
path: staging
127+
- name: Push package to feed 🐙
128+
id: push-feed
129+
shell: bash
130+
env:
131+
FEED_API_KEY: ${{ secrets.FEED_API_KEY }}
132+
FEED_SOURCE: ${{ secrets.FEED_SOURCE }}
133+
run: dotnet nuget push staging/**/*.nupkg --api-key "$FEED_API_KEY" --source "$FEED_SOURCE" --skip-duplicate

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ _ReSharper*/
3737
*.swp
3838
*.DotSettings
3939

40+
.idea/
4041
_NCrunch_LibGit2Sharp/
4142
artifacts/
4243
worktree.playlist

.idea/.idea.LibGit2Sharp/.idea/indexLayout.xml

Lines changed: 3 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

LibGit2Sharp.Tests/GlobalSettingsFixture.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,17 +90,17 @@ public void SetExtensions()
9090
var extensions = GlobalSettings.GetExtensions();
9191

9292
// Assert that "noop" is supported by default
93-
Assert.Equal(new[] { "noop", "objectformat", "worktreeconfig" }, extensions);
93+
Assert.Equal(new[] { "noop", "objectformat", "preciousobjects", "worktreeconfig" }, extensions);
9494

9595
// Disable "noop" extensions
9696
GlobalSettings.SetExtensions("!noop");
9797
extensions = GlobalSettings.GetExtensions();
98-
Assert.Equal(new[] { "objectformat", "worktreeconfig" }, extensions);
98+
Assert.Equal(new[] { "objectformat", "preciousobjects", "worktreeconfig" }, extensions);
9999

100100
// Enable two new extensions (it will reset the configuration and "noop" will be enabled)
101101
GlobalSettings.SetExtensions("partialclone", "newext");
102102
extensions = GlobalSettings.GetExtensions();
103-
Assert.Equal(new[] { "newext", "noop", "objectformat", "partialclone", "worktreeconfig" }, extensions);
103+
Assert.Equal(new[] { "newext", "noop", "objectformat", "partialclone", "preciousobjects", "worktreeconfig" }, extensions);
104104
}
105105

106106
[Fact]

LibGit2Sharp.Tests/LibGit2Sharp.Tests.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFrameworks Condition="'$(TargetFrameworks)'==''">net472;net6.0;net8.0;net9.0</TargetFrameworks>
4+
<TargetFrameworks Condition="'$(TargetFrameworks)'==''">net472;net8.0;net9.0</TargetFrameworks>
55
</PropertyGroup>
66

77
<ItemGroup>

LibGit2Sharp/Core/GitBlame.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,12 +61,15 @@ internal unsafe struct git_blame_hunk
6161
public git_oid final_commit_id;
6262
public UIntPtr final_start_line_number;
6363
public git_signature* final_signature;
64+
public git_signature* final_committer;
6465

6566
public git_oid orig_commit_id;
6667
public char* orig_path;
6768
public UIntPtr orig_start_line_number;
6869
public git_signature* orig_signature;
70+
public git_signature* orig_committer;
6971

72+
public char* summary;
7073
public byte boundary;
7174
}
7275

LibGit2Sharp/Core/GitCertificateSsh.cs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
using System.Runtime.InteropServices;
1+
using System;
2+
using System.Runtime.InteropServices;
23

34
namespace LibGit2Sharp.Core
45
{
@@ -17,5 +18,14 @@ internal unsafe struct git_certificate_ssh
1718
/// The SHA1 hash (if appropriate)
1819
/// </summary>
1920
public unsafe fixed byte HashSHA1[20];
21+
22+
/// <summary>
23+
/// The SHA256 hash (if appropriate)
24+
/// </summary>
25+
public unsafe fixed byte HashSHA256[32];
26+
27+
public int raw_type;
28+
public byte* hostkey;
29+
public UIntPtr hostkey_len;
2030
}
2131
}

LibGit2Sharp/Core/GitCertificateSshType.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,6 @@ internal enum GitCertificateSshType
77
{
88
MD5 = (1 << 0),
99
SHA1 = (1 << 1),
10+
SHA256 = (1 << 2),
1011
}
1112
}

LibGit2Sharp/Core/GitCheckoutOpts.cs

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,9 @@ namespace LibGit2Sharp.Core
77
internal enum CheckoutStrategy
88
{
99
/// <summary>
10-
/// Default is a dry run, no actual updates.
10+
/// Allow safe updates that cannot overwrite uncommitted data.
1111
/// </summary>
12-
GIT_CHECKOUT_NONE = 0,
13-
14-
/// <summary>
15-
/// Allow safe updates that cannot overwrite uncommited data.
16-
/// </summary>
17-
GIT_CHECKOUT_SAFE = (1 << 0),
12+
GIT_CHECKOUT_SAFE = 0,
1813

1914
/// <summary>
2015
/// Allow update of entries in working dir that are modified from HEAD.
@@ -105,6 +100,22 @@ internal enum CheckoutStrategy
105100
/// </summary>
106101
GIT_CHECKOUT_DONT_WRITE_INDEX = (1 << 23),
107102

103+
/// <summary>
104+
/// Perform a dry run, reporting what would be done but without
105+
/// actually making changes in the working directory or the index.
106+
/// </summary>
107+
GIT_CHECKOUT_DRY_RUN = (1 << 24),
108+
109+
/// <summary>
110+
/// Include common ancestor data in zdiff3 format for conflicts.
111+
/// </summary>
112+
GIT_CHECKOUT_CONFLICT_STYLE_ZDIFF3 = (1 << 25),
113+
114+
/// <summary>
115+
/// Do not do a checkout and do not fire callbacks.
116+
/// </summary>
117+
GIT_CHECKOUT_NONE = (1 << 30),
118+
108119
// THE FOLLOWING OPTIONS ARE NOT YET IMPLEMENTED
109120

110121
/// <summary>

LibGit2Sharp/Core/GitConfigEntry.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,5 @@ internal unsafe struct GitConfigEntry
1111
public char* origin_path;
1212
public uint include_depth;
1313
public uint level;
14-
public void* freePtr;
1514
}
1615
}

0 commit comments

Comments
 (0)