gitoxide
gitoxide copied to clipboard
Mergebase support
Should provide:
- [ ] Given two commits
a&bcheck ifbis ancestor ofa - [x] Given
ncommits, find the first common ancestor - [x] Given
ncommits, find their LCA- [x] Support corrected committer date (See git-commit-graph(1))
- [ ] the equivalent of
merge-base --independent(boils down toremove_redundant())
TODO
- [ ] assure commit-graphs aren't used if grafts are present (like in shallow clones), or if object-replacements are active.
Open Questions:
- How should the api look? Something like this?
impl Commit {
fn is_descendant(list: Vec<Id>) -> bool;
}
impl Repository {
/// Return the first found common ancestor
fn merge_base_first(one: Id, twos: Vec<Id>) -> Result<Option<Id>, Error>;
/// Return the first least common ancestor
fn merge_base(one: Id, twos: Vec<Id>) -> Result<Vec<Id>, Error>;
}
Further reading:
- https://github.com/git/git/blob/142430338477d9d1bb25be66267225fb58498d92/commit-reach.c#L434=
- https://devblogs.microsoft.com/devops/supercharging-the-git-commit-graph-iii-generations/
- https://web.archive.org/web/20190914030055/http://www.gghh.name:80/dibtp/2014/02/25/how-does-mercurial-select-the-greatest-common-ancestor.html
- https://web.archive.org/web/20160730054028/https://selenic.com/hg/rev/2f7186400a07