Is there an easy way to find all References (e.g. Tags) for a given Commit? For example:
using( Repository repo = new Repository( path_to_repo ) )
{
foreach( Commit commit in repo.Commits )
{
List<Reference> assignedRefs = commit.Refs; // <- how to do this?
}
}
The code below retrieves all the references that can reach the selected commit.
If you want to only retrieve
Tag
s, the method exposes an overload to help you with this.Note: This code will retrieve all refs that either directly point to the chosen commit or point to an ancestor of this commit. In this sense, it behaves similarly to the git rev-list command.
As @user1130329 pointed out, going through all refs multiple times can be very expensive. Just as an alternative, this is what I have done here for a similar case: