Betty Crokker
Betty Crokker

Reputation: 3373

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. This takes a VERY long time (10 seconds or so per file).

Is there a way to get the same information I get from "git log" using libgit2sharp?

Upvotes: 1

Views: 1059

Answers (1)

VonC
VonC

Reputation: 1328212

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

Even a regular git log (not filtered per file) can be slow on large repo.

Upvotes: 0

Related Questions