LibGit2Sharp equivalent to git diff --stat
I'm looking for a way to capture how many lines have changed in each file in my working directory - for example git diff --stat
in git - is there a way to do this using LibGit2Sharp?
I know I can get Total LinesAdded / Deleted from the patch, but I'm wondering how the file is by file.
+3
source to share
1 answer
Listed below are all the files that have changed between the two commits, as well as the number of changes (global, line additions, and line deletions).
var patch = repo.Diff.Compare<Patch>(fromCommit, untilCommit);
foreach (var pec in patch)
{
Console.WriteLine("{0} = {1} ({2}+ and {3}-)",
pec.Path,
pec.LinesAdded + pec.LinesDeleted,
pec.LinesAdded,
pec.LinesDeleted);
}
You need to access a specific file in Patch
, types provide an indexing facility to facilitate this
PatchEntryChanges entryChanges = patch["path/to/my/file.txt"];
+3
source to share