libgit2 / libgit2/libgit2sharp
Getting patch with unicode characters confuses git apply
未关闭
还没有人认领这个 Issue。
- 主要语言
- C#
- 星标
- 3.5k
- 派生
- 925
- PR 合并指标
- 30 天内没有已合并 PR
描述
var patches = repo0.Diff.Compare<Patch>(commit1?.Tree, commit2.Tree, Enumerable.Repeat(change.Path, 1), compareOptions: compareOptions);
Getting patches + applying them to file does not seems to work if there are unicode characters in file itself.
Have tried to save it in utf8, but problem still persists.
As a walkaround to this problem, I have added extra comparison that there aren't any unicode characters.
// If we have some unicode characters, then cannot be handled as text diff.
canBeHandledAsTextPatch = strpatches.All(c => c <= 255);
But, libgit itself has built in support for patching, See https://libgit2.org/libgit2/#HEAD, git_apply* function calls - but none of these operations seems to be supported in libgit2sharp.
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
首先通过 Diff.Compare 和现有的文本补丁处理来复现 Unicode 失败问题,然后检查 issue 中引用的 libgit2 git_apply* API。完成标准是:无需使用所述 workaround,即可正确获取并应用包含 Unicode 字符的文件的补丁。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- csharp, git
- 领域
- tooling
- Issue 类型
- 缺陷
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 活跃度
- 停滞
- 描述清晰度
- 需要澄清
- 新手友好度
- 32/100