libgit2 / libgit2/libgit2sharp
CheckoutConflictException on Commands.Checkout
还没有人认领这个 Issue。
- 主要语言
- C#
- 星标
- 3.5k
- 派生
- 925
- PR 合并指标
- 30 天内没有已合并 PR
描述
Hi!
I want to create a UI to make resolving conflicts for a user as easy as possible. At the moment after i have created a conflict by make some changes local and in the repository in the same line of the same file, i want to do first a checkout to get informations about the conflicted file
Reproduction steps
Here is my code to make the checkout of a given Repository:
public void Checkout()
{
try
{
UnityEngine.Debug.Log("starting checkout");
CheckoutOptions opts = new CheckoutOptions();
opts.OnCheckoutNotify = (string path, CheckoutNotifyFlags notify) =>
{
switch (notify)
{
case CheckoutNotifyFlags.Conflict:
UnityEngine.Debug.Log("conflicted file found at: " + path);
return true;
case CheckoutNotifyFlags.Ignored:
UnityEngine.Debug.Log("ignored file found at: " + path);
return true;
case CheckoutNotifyFlags.None:
UnityEngine.Debug.Log("unchanged file found at: " + path);
return true;
case CheckoutNotifyFlags.Untracked:
UnityEngine.Debug.Log("untracked file found at: " + path);
return true;
case CheckoutNotifyFlags.Updated:
UnityEngine.Debug.Log("updated file found at: " + path);
return true;
default:
UnityEngine.Debug.Log("dirty file at: " + path);
return true;
}
};
opts.CheckoutNotifyFlags = CheckoutNotifyFlags.None |
CheckoutNotifyFlags.Dirty |
CheckoutNotifyFlags.Ignored |
CheckoutNotifyFlags.Conflict |
CheckoutNotifyFlags.Untracked |
CheckoutNotifyFlags.Updated;
Branch actualRemote = Repo.Branches["origin/" + Repo.Head.FriendlyName];
Commands.Checkout(Repo, actualRemote.Tip.Tree, opts, "");
}
catch (CheckoutConflictException e)
{
UnityEngine.Debug.Log(e.Message);
}
}
Repo is the actual Repository, and it contains in my test example 1 conflicted file.
Expected behavior
I don't find any detailed guide, how to resolve conflicts with LibGit2Sharp, but if i understand it right, the checkout command should write the conflicted files in the ConflictCollection of the index of the repository.
Actual behavior
If i do the checkout with the code above, the conflicted file(s) will be found, but the catch-clause will be triggered and the ConflictCollection of Repo.Index will be still empty. Can somebody explain how this whole process works, how i can use it right and why the exception in the code will be triggered?
Version of LibGit2Sharp (release number or SHA1)
LibGit2Sharp v0.25.2
Operating system(s) tested; .NET runtime tested
Win 10 64bit, .NET Framework 4.6.1
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
从复现的 Commands.Checkout 调用、其对 CheckoutConflictException 的处理,以及在 LibGit2Sharp v0.25.2 上观察到的 Repo.Index ConflictCollection 状态开始。在所述的 Windows 和 .NET 环境中,使用提供的 Unity 示例比较 checkout 通知标志和异常行为。完成的标准是解释异常和冲突状态行为,或确定所需的文档或修正。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- csharp, git
- 领域
- devtools
- Issue 类型
- 缺陷
- 难度
- 3/5
- 预计耗时
- 1-2 天
- 活跃度
- 停滞
- 描述清晰度
- 需要澄清
- 新手友好度
- 25/100