Open vinayaugustine opened 7 years ago
Have you tried with 0.22.1 or the prereleases for 0.23? We had a bug in libgit2 where we'd allocate silly amounts of memory for trees in Windows, which I believe the native binaries for 0.22.0 had.
I upgraded to 0.23.1. I still get OutOfMemory error when I use Diff.Compare<Patch>()
. However, I then switched to using Diff.Compare<TreeChanges>()
and Diff.Compare<PatchStats>()
. That's been running for ~5 hours with no error. Is there any reason Patch
still fails?
Here's the updated version:
foreach (var currentCommit in Repository.Configuration.FilterCommits(branch.Commits))
{
if(null != nextCommit)
{
var changes = repo.Diff.Compare<TreeChanges>(currentCommit.Tree, nextCommit.Tree);
var stats = repo.Diff.Compare<PatchStats>(currentCommit.Tree, nextCommit.Tree);
foreach (var change in changes)
{
var data = new string[]
{
nextCommit.Id.Sha,
branch.FriendlyName,
change.Path,
change.Status.ToString(),
"false", // TODO remove: only available with Patch
GetFileSize(nextCommit, change.Path).ToString(),
GetLineCount(nextCommit, change.Path).ToString(),
stats[change.Path].LinesAdded.ToString(),
stats[change.Path].LinesDeleted.ToString()
};
yield return data;
}
}
nextCommit = currentCommit;
}
@vinayaugustine Hello, I am also looking for a way to count the number of lines of code for each person through LibGit2Sharp. Have you already solved it? Can you tell me how to do it?
I get an OutOfMemoryException from
Repository.Diff
with v0.22.0:I'm trying to produce some basic code churn statistics from a Git repository. As some context, I'm implementing this in an ASP.NET application in a Hangfire job.
For each branch, I'm iterating over all of the commits and comparing them to their predecessor. I generate a patch per commit, and generate data for each file path in the commit. Here is the code I'm using:
I found this related Stack Overflow question: libgit2sharp.Patch outofmemory. I tried changing my code to produce both a TreeChanges and a PatchStats, but it fails as well.