Getting Commits from one Branch

52 views
Skip to first unread message

Robert Neumeister

unread,
Apr 10, 2014, 4:29:04 AM4/10/14
to gits...@googlegroups.com
Hi there,

i have a problem to get all commits from one selected branch. I've tried to get the commits via the class PlotWalk but it gives me all commits from every branch.

The code looks like this:

var list = new GitSharp.Core.RevPlot.PlotCommitList();
var plot = new PlotWalk(repo);

plot.markStart(((GitSharp.Core.Repository)repo).getAllRefsByPeeledObjectId().Keys.Select(id => plot.parseCommit(id)));

list.Source(plot);
list.fillTo(1000);
foreach (var commit in list)
{
    Console.WriteLine(repo.Get<Commit>(commit.Name).Message);
}

Does anyone have an idea?

Robert Neumeister

unread,
Apr 10, 2014, 5:16:22 AM4/10/14
to gits...@googlegroups.com
Ok i think i got it.

If i get the Branch via var branch = new (repo,"name"); i can use branch.CurrentCommit.Parent to get older commits.

Commit commit = f.CurrentCommit;
Console.WriteLine(commit.Message);
while (commit.Parent != null)
{
     commit = commit.Parent;
     Console.WriteLine(commit.Message);
}

Reply all
Reply to author
Forward
0 new messages