简体   繁体   English

使用libgit2sharp进行“ git log”

[英]Using libgit2sharp to do “git log”

From the command line, I can type 在命令行中,我可以输入

git log myfile

and it will very quickly give me all the commits in which this file was updated. 它将很快给我所有更新此文件的提交。

Using libgit2sharp, the only way I've found to do this is scan through every single commit in my repository and query the commit for the files in that commit. 使用libgit2sharp,我发现这样做的唯一方法是扫描存储库中的每个提交,并查询该提交中的文件。 This takes a VERY long time (10 seconds or so per file). 这需要非常长的时间(每个文件10秒左右)。

Is there a way to get the same information I get from "git log" using libgit2sharp? 有没有办法使用libgit2sharp从“ git log”中获得相同的信息?

Filtering commits seems indeed 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);

This is introduced in 2015 by commit c462df3 2015年由commit c462df3引入

Even a regular git log (not filtered per file) can be slow on large repo . 在大型repo上,即使是常规的git log (未按文件过滤)也会很慢

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM