Aim*_*ast 2 libgit2 libgit2sharp
例如,该行的.gitattributes文件.代码的输出lg2s*.cs diff=csharp
using (var repo = new Repository(@"path\to\lg2s"))
{
var tree1 = repo.Lookup<Commit>("a845db9").Tree;
var tree2 = repo.Lookup<Commit>("d677741").Tree;
var patches = repo.Diff.Compare<Patch>(tree1, tree2);
foreach (var patch in patches)
{
Console.WriteLine(patch.Patch);
}
}
Run Code Online (Sandbox Code Playgroud)
是(不久)
diff --git a/LibGit2Sharp/RepositoryStatus.cs b/LibGit2Sharp/RepositoryStatus.cs
@@ -59,8 +59,8 @@ namespace LibGit2Sharp
Run Code Online (Sandbox Code Playgroud)
但输出git bash是(很快)
diff --git a/LibGit2Sharp/RepositoryStatus.cs b/LibGit2Sharp/RepositoryStatus.cs
@@ -59,8 +59,8 @@ internal RepositoryStatus(Repository repo, StatusOptions optio
Run Code Online (Sandbox Code Playgroud)
第二行不一样.
看起来有一个深入的讨论Add .gitattributes support libgit2 /#508,但PR Add APIs for git attributes libgit2 /#516是否合并?
现在支持多少种语言?
我们可以指定没有gitattributes文件的规则吗?
小智 6
这实际上是差异驱动器和差异的自定义函数上下文规则的问题,而不是属性之一.
那些文件确实有diff=csharp属性; 问题是该属性并不意味着什么libgit2.
当git和libgit2产生的diff,他们使用正则表达式在其中找到一个差异大块发生函数的名称.如果没有正则表达式可用于查找不以空格开头的第一行,它们也有一个回退规则.
git包含一个内置差异驱动程序的表,其中包含驱动程序的定义csharp.
libgit2不包含该表(如在合并差异驱动程序支持的PR中讨论的那样),因此没有内置的概念用于使用什么模式diff=csharp.
您解决此问题的替代方案是:
.git/config文件(或您的$HOME/.gitconfig)中创建diff.csharp.xfuncname一个用搜索模式实现的条目,或者libgit2导入驱动程序定义.导入的问题(以及我没有接受它的原因)是它将涉及获得代码原始作者的许可以重新许可它以供使用libgit2.如果您决定启动Pull Request并且您获得CSharp xfuncname模式的作者同意重新授权代码libgit2,请告诉我,我将很乐意就实际实施进行协作!
| 归档时间: |
|
| 查看次数: |
998 次 |
| 最近记录: |