Iterate commits and parents

This commit is contained in:
David Doblas Jiménez 2024-05-16 12:01:30 +02:00
parent 7fbf6640f6
commit d53322c256

View File

@ -129,6 +129,21 @@ def get_commit(oid):
return Commit(tree=tree, parent=parent, message=message)
def iter_commits_and_parents(oids):
oids = set(oids)
visited = set()
while oids:
oid = oids.pop()
if not oid or oid in visited:
continue
visited.add(oid)
yield oid
commit = get_commit(oid)
oids.add(commit.parent)
def get_oid(name):
if name == "@":
name = "HEAD"