Update bundled libgit2 to >= 1.9.4 for relativeWorktrees support

Open
#2,184 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
48/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Quiet
Tech stack
csharp, git
Domain
build-system

Research direction

Start with the Repository constructor entry point and the project’s bundled native libgit2 configuration. Reproduce the failure using a worktree with extensions.relativeWorktrees enabled, then verify that the bundled libgit2 version is at least 1.9.4 and that opening the repository succeeds on Linux/.NET 8.0.

Written by the indexing model from the issue text.

Description

Reproduction steps

Use LibGit2Sharp to open a repository/worktree created by Git with relative worktree paths enabled. Modern Git can set this automatically when a worktree is created or repaired with relative paths.

A minimal repository state has core.repositoryformatversion = 1 and the newer Git extension:

[extensions]
    relativeWorktrees = true

A linked worktree may have a .git file like:

gitdir: ../worktrees/my-worktree

Then open the worktree with LibGit2Sharp:

using LibGit2Sharp;

using var repo = new Repository("/path/to/my-worktree");

This also reproduces through downstream tools that depend on LibGit2Sharp. In my case, GitVersion.MsBuild 6.7.0 launches its bundled GitVersion tool, which bundles LibGit2Sharp 0.31.0 and native libgit2 1.8.4, and fails while opening the repository.

Expected behavior

LibGit2Sharp should open repositories/worktrees that use Git's extensions.relativeWorktrees extension.

The upstream libgit2 issue was fixed here:

The fix is included in libgit2 v1.9.4:

Actual behavior

Opening the repository fails before any repository operations can run:

LibGit2Sharp.LibGit2SharpException: unsupported extension name extensions.relativeworktrees
   at LibGit2Sharp.Core.Ensure.HandleError(Int32 result)
   at LibGit2Sharp.Core.Ensure.ZeroResult(Int32 result)
   at LibGit2Sharp.Core.Proxy.git_repository_open(String path)
   at LibGit2Sharp.Repository..ctor(String path, RepositoryOptions options, RepositoryRequiredParameter requiredParameter)
   at LibGit2Sharp.Repository..ctor(String path)
Version of LibGit2Sharp (release number or SHA1)

Observed via downstream GitVersion.MsBuild 6.7.0, which bundles:

LibGit2Sharp 0.31.0
native libgit2 1.8.4

The requested dependency update is for a LibGit2Sharp release that bundles native libgit2 >= 1.9.4.

Operating system(s) tested; .NET runtime tested

Tested on Linux / WSL2 with .NET 8.0.

Git version in the environment:

git version 2.51.2
Downstream dependency-chain impact

This blocks tools that consume LibGit2Sharp indirectly, notably GitVersion. I am filing a corresponding GitVersion issue as well, because GitVersion cannot fix this until LibGit2Sharp publishes a release with libgit2 >= 1.9.4.

Dominant language
C#
Stars
3.5k
Forks
925
PR merge metrics
No merged PRs in 30d

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from libgit2/libgit2sharp

All issues in libgit2/libgit2sharp

Similar issues

More C# issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.