1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
use git_hash::ObjectId;
use git_traverse::commit::{ancestors, Ancestors};
pub trait Sealed {}
pub type AncestorsIter<Find> = Ancestors<Find, fn(&git_hash::oid) -> bool, ancestors::State>;
pub trait ObjectIdExt: Sealed {
fn ancestors<Find, E>(self, find: Find) -> AncestorsIter<Find>
where
Find: for<'a> FnMut(&git_hash::oid, &'a mut Vec<u8>) -> Result<git_object::CommitRefIter<'a>, E>,
E: std::error::Error + Send + Sync + 'static;
fn attach(self, repo: &crate::Repository) -> crate::Id<'_>;
}
impl Sealed for ObjectId {}
impl ObjectIdExt for ObjectId {
fn ancestors<Find, E>(self, find: Find) -> AncestorsIter<Find>
where
Find: for<'a> FnMut(&git_hash::oid, &'a mut Vec<u8>) -> Result<git_object::CommitRefIter<'a>, E>,
E: std::error::Error + Send + Sync + 'static,
{
Ancestors::new(Some(self), ancestors::State::default(), find)
}
fn attach(self, repo: &crate::Repository) -> crate::Id<'_> {
crate::Id::from_id(self, repo)
}
}