List commits that are reachable by following the parent links from the given commit (like `git rev-list`)

Is there a way to list all commits that are reachable from HEAD using libgit2sharp library like git rev-list HEAD do?

There is a function ReferenceCollectionException.ReachableFrom, but it returns the list of refs pointed at particular commit:

let repo = new Repository("C:\path\to\repo")
let c = repo.Lookup<Commit>("HEAD")
let commits = repo.Refs.ReachableFrom([c])

And commits contains only 4 elements:

[ refs/heads/vNext => "63f8d6d90f06f4578604b57502f2c6b8aabf4479"
, refs/remotes/origin/HEAD => refs/remotes/origin/vNext => "63f8d6d90f06f4578604b57502f2c6b8aabf4479"
, refs/remotes/origin/ntk/issue_953 => "d5ced8c64e5ea9f6ba2135a72d59da2208215c6c"
, refs/remotes/origin/vNext => "63f8d6d90f06f4578604b57502f2c6b8aabf4479"
]

But there are much more nested parents commits of HEAD:

>> git rev-list HEAD | wc -l
1730

  • Specify options with git commands via LibGit2Sharp
  • LibGit2Sharp authentication in server side application
  • How to retrieve the branch where a commit was created originally using LibGit2Sharp?
  • Use LibGit2Sharp at Azure Cloud Service
  • LibGit2Sharp equivalent for git describe --contains
  • Git stash on windows extremly slow compared to Libgit2
  • Create a folder structure using LibGit2Sharp?
  • Searching file in branch
  • One Solution collect form web for “List commits that are reachable by following the parent links from the given commit (like `git rev-list`)”

    The following piece of code should help you accomplish what you’re after

    var filter = new CommitFilter { Since = repo.Head };
    
    foreach (var commit in repo.Commits.QueryBy(filter))
    {
        Console.WriteLine(commit.Sha);
    }
    
    Git Baby is a git and github fan, let's start git clone.