Add change 27 to instructions
This commit is contained in:
21
how_to/Change_27.md
Normal file
21
how_to/Change_27.md
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
- 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.)
|
||||||
Reference in New Issue
Block a user