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 摘要。