libgit2 / libgit2/libgit2sharp
Libgit2sharp CheckoutPaths() doesn't undo changes on file with status "NewInIndex, ModifiedInWorkdir".
还没有人认领这个 Issue。
- 主要语言
- C#
- 星标
- 3.5k
- 派生
- 925
- PR 合并指标
- 30 天内没有已合并 PR
描述
You are opening a bug report against the LibGit2Sharp project: we
use GitHub Issues for tracking bug reports and feature requests. If
you have a question about an API or usage, please ask on StackOverflow:
http://stackoverflow.com/questions/tagged/libgit2sharp.
Otherwise, to report a bug, please fill out the reproduction steps
(below) and delete these introductory paragraphs. Thanks!
Reproduction steps
I have a file inside many folders (for ex : docs/jsons/myfile.json ) in my repository
I staged the file , so it now has the status "NewInIndex".
After that i made changes on that file.
It has now the status "NewInIndex, ModifiedInWorkdir".
My code is the following :
using ( var repo = new Repository("my repo path")
{
CheckoutOptions options = new CheckoutOptions { CheckoutModifiers = CheckoutModifiers.Force };
repo.CheckoutPaths(repo.Head.FriendlyName, new string[] {"docs/jsons/myfile.json"} , options );
}
I also tried to replace " repo.Head.FriendlyName" by "repo.Head.CannonicalName" and by "repo.Head.Tip.Id.Sha"
Expected behavior
I expect the file to get back to its previous content, and to have the status "NewInIndex" again.
Actual behavior
The file's content doesnt change and its status is still : "NewInIndex, ModifiedInWorkdir".
Version of LibGit2Sharp (release number or SHA1)
LibGit2Sharp version 0.26.2
Operating system(s) tested; .NET runtime tested
Window 10 Enterprise
.NET 6.0
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
从 CheckoutPaths API 开始,使用提供的路径和 CheckoutOptions,重现一个标记为 NewInIndex、ModifiedInWorkdir 的文件所报告的状态转换。验证强制 checkout 会恢复已暂存的内容,并使文件保持 NewInIndex 状态,以报告的 LibGit2Sharp 0.26.2 行为作为基准。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- csharp, git
- 领域
- devtools
- Issue 类型
- 缺陷
- 难度
- 3/5
- 预计耗时
- 1-2 天
- 活跃度
- 停滞
- 描述清晰度
- 基本清楚
- 新手友好度
- 45/100