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

  • Replace '^M`(crlf) with '\n'(lf) (new line) in a cloned git repo to get correct git blame?
  • How to trigger “Merged” status for a pull request with commit message
  • How to include two different folders into the same git project?
  • How to set up a mirror repo on GitHub
  • Missing git commits over http but available over ssh
  • How to git clone an OpenShift application to Android
  • 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.