22 lines
906 B
Markdown
22 lines
906 B
Markdown
- k: Iterate commits and parents
|
|
|
|
In addition to printing the refs, we'll also print all OIDs that are reachable
|
|
from those refs. We'll create `iter_commits_and_parents`, which is a generator
|
|
that returns all commits that it can reach from a given set of OIDs.
|
|
|
|
Note that `iter_commits_and_parents` will return an OID once, even if it's
|
|
reachable from multiple refs. Here, for example:
|
|
```
|
|
o<----o<----o<----o<----@<----@<----@
|
|
^ \ ^
|
|
first commit -<--$<----$ refs/tags/tag1
|
|
^
|
|
refs/tags/tag2
|
|
```
|
|
|
|
We can reach the first commit by following the parents of *tag1* or by following
|
|
the parents of *tag2*. Yet if we call `iter_commits_and_parents({tag1, tag2})`,
|
|
the first commit will be yielded only once. This property will be useful later.
|
|
|
|
(Note that nothing is visualized yet, we're preparing for that.)
|