Update bundled libgit2 to >= 1.9.4 for relativeWorktrees support

未关闭
#2,184 1 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
3/5
预计耗时
1-2 天
新手友好度
48/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
冷清
技术栈
csharp, git
领域
build-system

调研方向

从 Repository 构造函数入口点和项目中捆绑的原生 libgit2 配置入手。使用启用 extensions.relativeWorktrees 的 worktree 重现该故障,然后验证捆绑的 libgit2 版本至少为 1.9.4,并确认在 Linux/.NET 8.0 上可以成功打开仓库。

由索引模型根据 Issue 内容生成。

描述

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.

主要语言
C#
星标
3.5k
派生
925
PR 合并指标
30 天内没有已合并 PR

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

libgit2/libgit2sharp 的其他 Issue

查看 libgit2/libgit2sharp 的全部 Issue

相似的 Issue

更多 C# Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。