Skip to content

Commit c612440

Browse files
committed
feat: add Reference::peel_to_id_in_place_packed() to allow passing a packed-buffer snapshot.
This is useful for speeding up reference lookups as otherwise, it will have to validate the packed-buffer snapshot didn't change internally each time a ref is peeled.
1 parent 6f2eb91 commit c612440

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

gix/src/reference/mod.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,20 @@ impl<'repo> Reference<'repo> {
7474
Ok(Id::from_id(oid, self.repo))
7575
}
7676

77+
/// Follow all symbolic targets this reference might point to and peel the underlying object
78+
/// to the end of the chain, and return it, reusing the `packed` buffer if available.
79+
///
80+
/// This is useful to learn where this reference is ultimately pointing to.
81+
pub fn peel_to_id_in_place_packed(
82+
&mut self,
83+
packed: Option<&gix_ref::packed::Buffer>,
84+
) -> Result<Id<'repo>, peel::Error> {
85+
let oid = self
86+
.inner
87+
.peel_to_id_in_place_packed(&self.repo.refs, &self.repo.objects, packed)?;
88+
Ok(Id::from_id(oid, self.repo))
89+
}
90+
7791
/// Similar to [`peel_to_id_in_place()`][Reference::peel_to_id_in_place()], but consumes this instance.
7892
pub fn into_fully_peeled_id(mut self) -> Result<Id<'repo>, peel::Error> {
7993
self.peel_to_id_in_place()

0 commit comments

Comments
 (0)