How to ignore the merge using libgit2sharp?
1 answer
Merge reconciliation is a multi-parent commit.
To do this with Git, one could specify, for example, the following command, which would list all commits reachable by HEAD that are not commits.
git log --no-merges HEAD
Where is documented as "Do not print commits with multiple parents. Same as --max-parents = 1.".--no-merges
You can do the same with LibGit2Sharp with the following piece of code:
using (var repo = new Repository(path))
{
var allCommitsReachableByHead = repo.Commits;
const string RFC2822Format = "ddd dd MMM HH:mm:ss yyyy K";
foreach (var c in allCommitsReachableByHead)
{
if (c.Parents.Count() > 1)
{
continue;
}
Console.WriteLine("Author: {0} <{1}>", c.Author.Name, c.Author.Email);
Console.WriteLine("Date: {0}", c.Author.When.ToString(RFC2822Format, CultureInfo.InvariantCulture));
Console.WriteLine();
Console.WriteLine(c.Message);
Console.WriteLine();
}
}
+5
source to share