Repository navigation
Commit 4450673
committed
fix(commit): don't skip a parent when
`Commit.iter_parents()` runs `git rev-list <self> -- <paths>` and forces
`--skip=1` to drop the commit itself. That only works when rev-list lists
the commit. With `paths` the commit doesn't touch, or a filter such as
`grep` or `author` it doesn't match, rev-list never lists it, and the skip
throws away the newest real parent instead:
A1 (a) <- A2 (a) <- B (b)
B.iter_parents(paths="a") -> [A1] # git rev-list B^ -- a: A2 A1
When `paths` or other rev-list options are given, ask rev-list for its
first commit under the same options and only count the commit itself
in `skip` when it is that commit. Calls without paths or filters keep
the single rev-list call. `skip` keeps its existing meaning: 0 and 1 drop
only the commit itself, larger values also drop parents.
`test_iter_parents_when_self_is_filtered_out` covers paths, `skip`,
`max_count`, `reverse`, `first_parent` on a merge and `grep`; it fails
without this change under both the `cli` and `gix` backends.
Agent-Model: claude-opus-5-5iter_parents filters out self1 parent 029964a commit 4450673
3 files changed
Lines changed: 31 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
489 | 489 | | |
490 | 490 | | |
491 | 491 | | |
| 492 | + | |
| 493 | + | |
| 494 | + | |
| 495 | + | |
| 496 | + | |
| 497 | + | |
492 | 498 | | |
493 | 499 | | |
494 | 500 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
476 | 476 | | |
477 | 477 | | |
478 | 478 | | |
| 479 | + | |
| 480 | + | |
| 481 | + | |
| 482 | + | |
| 483 | + | |
| 484 | + | |
| 485 | + | |
| 486 | + | |
| 487 | + | |
| 488 | + | |
| 489 | + | |
| 490 | + | |
| 491 | + | |
| 492 | + | |
| 493 | + | |
479 | 494 | | |
480 | 495 | | |
481 | 496 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
33 | 33 | | |
34 | 34 | | |
35 | 35 | | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
36 | 46 | | |
37 | 47 | | |
38 | 48 | | |
| |||
0 commit comments