libgit2 / libgit2/libgit2sharp

Setting tracking branch fails with "ref 'refs/remotes/origin/master' doesn't match the destination"

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

还没有人认领这个 Issue。

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

描述

Reproduction steps
  • a repo with multiple overlapping fetch specs:
[remote "origin"]
	url = ../multifetchspec_testrepo.git/
	fetch = +refs/pull/28/head:refs/remotes/origin/PR-28
	fetch = +refs/heads/master:refs/remotes/origin/master
	fetch = +refs/heads/*:refs/remotes/origin/*
  • repo doesn't have local master branch (but remote does)
  • call repo.Branches.Update("master", b => b.TrackedBranch = trackedBranch.CanonicalName); (with trackedBranch pointing to refs/remotes/origin/master).
Expected behavior

Tracking branch gets set.

Actual behavior

Exception:

LibGit2Sharp.LibGit2SharpException: ref 'refs/remotes/origin/master' doesn't match the destination

LibGit2Sharp.LibGit2SharpException
ref 'refs/remotes/origin/master' doesn't match the destination
   at LibGit2Sharp.Core.Ensure.HandleError(Int32 result) in D:\Develop\libgit2sharp\LibGit2Sharp\Core\Ensure.cs:line 154
   at LibGit2Sharp.Core.Ensure.ZeroResult(Int32 result) in D:\Develop\libgit2sharp\LibGit2Sharp\Core\Ensure.cs:line 172
   at LibGit2Sharp.Core.Proxy.git_refspec_rtransform(IntPtr refSpecPtr, String name) in D:\Develop\libgit2sharp\LibGit2Sharp\Core\Proxy.cs:line 2085
   at LibGit2Sharp.Remote.FetchSpecTransformToSource(String reference) in D:\Develop\libgit2sharp\LibGit2Sharp\Remote.cs:line 138
   at LibGit2Sharp.BranchUpdater.GetUpstreamInformation(String canonicalName, String& remoteName, String& mergeBranchName) in D:\Develop\libgit2sharp\LibGit2Sharp\BranchUpdater.cs:line 188
   at LibGit2Sharp.BranchUpdater.SetUpstream(String upstreamBranchName) in D:\Develop\libgit2sharp\LibGit2Sharp\BranchUpdater.cs:line 116
   at LibGit2Sharp.BranchUpdater.set_TrackedBranch(String value) in D:\Develop\libgit2sharp\LibGit2Sharp\BranchUpdater.cs:line 53
   at LibGit2Sharp.Tests.BranchFixture.<>c__DisplayClass43_0.<CanSetTrackedBranch_MultipleFetchSpecs>b__0(BranchUpdater b) in D:\Develop\libgit2sharp\LibGit2Sharp.Tests\BranchFixture.cs:line 898
   at LibGit2Sharp.BranchCollection.Update(Branch branch, Action`1[] actions) in D:\Develop\libgit2sharp\LibGit2Sharp\BranchCollection.cs:line 292
Version of LibGit2Sharp (release number or SHA1)

4de700fedf87a5c9de10b921a636cc2f21d8964d

Operating system(s) tested; .NET runtime tested

Windows 10, Ubuntu 18.04

贡献指南

打开贡献指南

从这里开始

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

调研方向

从 LibGit2Sharp.Tests/BranchFixture.cs 中失败的测试 CanSetTrackedBranch_MultipleFetchSpecs 开始。使用复现中的重叠 fetch 规范,跟踪 BranchUpdater.GetUpstreamInformation 和 Remote.FetchSpecTransformToSource。当设置跟踪分支成功,并且回归测试在所述场景中通过时,该问题就完成了。

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

评估

技术栈
csharp, git
领域
devtools
Issue 类型
缺陷
难度
3/5
预计耗时
1-2 天
活跃度
停滞
描述清晰度
描述清楚
新手友好度
35/100

把新 issue 发到你的邮箱

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