【问题标题】:Using libgit2sharp to do "git log"使用 libgit2sharp 做“git log”
【发布时间】:2018-11-27 18:34:17
【问题描述】:

从命令行,我可以输入

git log myfile

它会很快为我提供更新此文件的所有提交。

使用 libgit2sharp,我发现这样做的唯一方法是扫描我的存储库中的每一个提交,并在提交中查询该提交中的文件。这需要很长时间(每个文件 10 秒左右)。

有没有办法使用 libgit2sharp 从“git log”获取相同的信息?

【问题讨论】:

    标签: c# git libgit2sharp


    【解决方案1】:

    过滤提交似乎确实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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-08-01
      • 1970-01-01
      • 1970-01-01
      • 2023-03-28
      • 1970-01-01
      • 1970-01-01
      • 2018-08-08
      • 1970-01-01
      相关资源
      最近更新 更多