【发布时间】:2018-11-27 18:34:17
【问题描述】:
从命令行,我可以输入
git log myfile
它会很快为我提供更新此文件的所有提交。
使用 libgit2sharp,我发现这样做的唯一方法是扫描我的存储库中的每一个提交,并在提交中查询该提交中的文件。这需要很长时间(每个文件 10 秒左右)。
有没有办法使用 libgit2sharp 从“git log”获取相同的信息?
【问题讨论】:
标签: c# git libgit2sharp
从命令行,我可以输入
git log myfile
它会很快为我提供更新此文件的所有提交。
使用 libgit2sharp,我发现这样做的唯一方法是扫描我的存储库中的每一个提交,并在提交中查询该提交中的文件。这需要很长时间(每个文件 10 秒左右)。
有没有办法使用 libgit2sharp 从“git log”获取相同的信息?
【问题讨论】:
标签: c# git libgit2sharp
过滤提交似乎确实the way tests are implemented:
// $ git log --follow --format=oneline untouched.txt
// c10c1d5f74b76f20386d18674bf63fbee6995061 Initial commit
fileHistoryEntries = repo.Commits.QueryBy("untouched.txt").ToList();
Assert.Single(fileHistoryEntries);
Assert.Equal("c10c1d5f74b76f20386d18674bf63fbee6995061", fileHistoryEntries[0].Commit.Sha);
这是introduced in 2015 by commit c462df3
即使是regular git log (not filtered per file) can be slow on large repo。
【讨论】: