Is there some convention for the order of a commit's parents?
Because one of the commit's parents should be to be to previous commit on the current branch that is being merged into and the rest are previous commits of the other merging branches.
I would like to identify the previous commit of the current branch, I'm using pygit
which returns a list of parents for a commit and intuitively I thought maybe the order of parents has significance but I have found no explicit mention of this.
I wrote this utility function, using first parent commit to traverse branch :
def walk_branch(pygit_repository, branch_oid):
"""
Walk a single branch
"""
from pygit2 import GIT_SORT_TOPOLOGICAL
previous_first_parent_oid = None
for commit in pygit_repository.walk(branch_oid, GIT_SORT_TOPOLOGICAL):
if previous_first_parent_oid is None or commit.oid == previous_first_parent_oid:
previous_first_parent_oid = commit.parents[0].oid if len(commit.parents) else None
yield commit