dedicated is-ancestor / reachability check (like git merge-base --is-ancestor)
#2914
Konstantin Vyatkin (tinovyatkin)
started this conversation in
Feature Proposal
Replies: 1 comment 1 reply
|
I recommend using the It seems two version of the function, With that said, using |
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Summary
There is currently no dedicated API to ask "is commit A an ancestor of commit B", equivalent to
git merge-base --is-ancestor.Current workaround
This works, but:
git merge-base --is-ancestorcan short-circuit as soon as the candidate ancestor is reached;NotFounderror variant, which callers must pattern-match and translate tofalse, mixing an expected outcome into the error path.Proposal
Something like
Repository::is_ancestor(ancestor, descendant) -> Result<bool, Error>(naming aside), ideally reusing the commit-graph when available likemerge_base_with_graphdoes, and treating disjoint histories asOk(false).Context
Needed for a repository-history walker (per-file churn/ownership metrics in mehen) that partitions changes accumulated under a path between a renamed lineage and a newer occupant of the same path by commit ancestry — potentially several reachability queries per rename encountered in the walk, where the merge-base allocation and non-short-circuiting traversal are pure overhead.
All reactions