How may I find all commits in a repository that have a specific parent?
For example, if I have a commit A
, I would like to find all other commits that share the parent with A
. What would be the most effective, i.e. performant yet correct way to do this in LibGit2Sharp?
That's a tricky question ;-)
The Git object allows to retrieve the parents of a commit. However, there's no easy way to find the children of a commit.
The following code would however partially solve this. The idea is to perform a
git log
from all the references of the repository (heads, tags, ...) and, along the way, select every commit which bear a parent with the requested SHA.As the walk is being done from the most recent commits down the ancestor path, it may take some time, if you're searching for the children of a very early commit in a repository with a very large history and many branches.
Limits:
Test repository:
The content of the repository being queried is show below