Skip to content

Commit 0380496

Browse files
committed
feat: replace Reference::peel_to_id_in_place_packed
Also, update documentation where it was still referring to deprecated `in_place` methods to refer to the new methods instead.
1 parent 51f998f commit 0380496

File tree

7 files changed

+28
-12
lines changed

7 files changed

+28
-12
lines changed

gix-ref/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ pub enum Kind {
148148
Object,
149149
/// A ref that points to another reference, adding a level of indirection.
150150
///
151-
/// It can be resolved to an id using the [`peel_in_place_to_id()`][`crate::file::ReferenceExt::peel_to_id_in_place()`] method.
151+
/// It can be resolved to an id using the [`peel_to_id()`][`crate::file::ReferenceExt::peel_to_id()`] method.
152152
Symbolic,
153153
}
154154

gix-ref/src/peel.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
pub mod to_id {
33
use gix_object::bstr::BString;
44

5-
/// The error returned by [`crate::file::ReferenceExt::peel_to_id_in_place()`].
5+
/// The error returned by [`crate::file::ReferenceExt::peel_to_id()`].
66
#[derive(Debug, thiserror::Error)]
77
#[allow(missing_docs)]
88
pub enum Error {
@@ -21,7 +21,7 @@ pub mod to_object {
2121

2222
use crate::file;
2323

24-
/// The error returned by [`file::ReferenceExt::follow_to_object_in_place_packed()`].
24+
/// The error returned by [`file::ReferenceExt::follow_to_object_packed()`].
2525
#[derive(Debug, thiserror::Error)]
2626
#[allow(missing_docs)]
2727
pub enum Error {

gix-ref/src/raw.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ pub struct Reference {
1212
pub target: Target,
1313
/// The fully peeled object to which this reference ultimately points to after following all symbolic refs and all annotated
1414
/// tags. Only guaranteed to be set after
15-
/// [`Reference::peel_to_id_in_place()`](crate::file::ReferenceExt) was called or if this reference originated
15+
/// [`Reference::peel_to_id()`](crate::file::ReferenceExt::peel_to_id) was called or if this reference originated
1616
/// from a packed ref.
1717
pub peeled: Option<ObjectId>,
1818
}

gix-ref/src/store/file/raw_ext.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,8 @@ pub trait ReferenceExt: Sealed {
5858
packed: Option<&packed::Buffer>,
5959
) -> Result<ObjectId, peel::to_id::Error>;
6060

61-
/// Like [`ReferenceExt::peel_to_id_in_place()`], but with support for a known stable `packed` buffer
62-
/// to use for resolving symbolic links.
61+
/// Like [`ReferenceExt::peel_to_id()`], but with support for a known stable `packed` buffer to
62+
/// use for resolving symbolic links.
6363
fn peel_to_id_packed(
6464
&mut self,
6565
store: &file::Store,

gix/src/reference/errors.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ pub mod edit {
2222

2323
///
2424
pub mod peel {
25-
/// The error returned by [`Reference::peel_to_id_in_place(…)`](crate::Reference::peel_to_id_in_place()) and
26-
/// [`Reference::into_fully_peeled_id()`](crate::Reference::into_fully_peeled_id()).
25+
/// The error returned by [`Reference::peel_to_id()`](crate::Reference::peel_to_id()) and
26+
/// [`Reference::into_fully_peeled_id()`](crate::Reference::into_fully_peeled_id()).
2727
#[derive(Debug, thiserror::Error)]
2828
#[allow(missing_docs)]
2929
pub enum Error {

gix/src/reference/iter.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ impl<'repo> Platform<'repo> {
9090
impl Iter<'_, '_> {
9191
/// Automatically peel references before yielding them during iteration.
9292
///
93-
/// This has the same effect as using `iter.map(|r| {r.peel_to_id_in_place(); r})`.
93+
/// This has the same effect as using `iter.map(|r| {r.peel_to_id(); r})`.
9494
///
9595
/// # Note
9696
///

gix/src/reference/mod.rs

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,8 @@ impl<'repo> Reference<'repo> {
8181
/// This is useful to learn where this reference is ultimately pointing to after following
8282
/// the chain of symbolic refs and annotated tags.
8383
///
84-
/// Note that this method mutates `self` in place if it does not already point to non-symbolic
85-
/// object.
84+
/// Note that this method mutates `self` in place if it does not already point to a
85+
/// non-symbolic object.
8686
pub fn peel_to_id(&mut self) -> Result<Id<'repo>, peel::Error> {
8787
let oid = self.inner.peel_to_id(&self.repo.refs, &self.repo.objects)?;
8888
Ok(Id::from_id(oid, self.repo))
@@ -93,6 +93,7 @@ impl<'repo> Reference<'repo> {
9393
///
9494
/// This is useful to learn where this reference is ultimately pointing to after following
9595
/// the chain of symbolic refs and annotated tags.
96+
#[deprecated = "Use `peel_to_id_packed()` instead"]
9697
pub fn peel_to_id_in_place_packed(
9798
&mut self,
9899
packed: Option<&gix_ref::packed::Buffer>,
@@ -103,6 +104,21 @@ impl<'repo> Reference<'repo> {
103104
Ok(Id::from_id(oid, self.repo))
104105
}
105106

107+
/// Follow all symbolic targets this reference might point to and peel all annotated tags
108+
/// to their first non-tag target, and return it, reusing the `packed` buffer if available.
109+
///
110+
/// This is useful to learn where this reference is ultimately pointing to after following
111+
/// the chain of symbolic refs and annotated tags.
112+
///
113+
/// Note that this method mutates `self` in place if it does not already point to a
114+
/// non-symbolic object.
115+
pub fn peel_to_id_packed(&mut self, packed: Option<&gix_ref::packed::Buffer>) -> Result<Id<'repo>, peel::Error> {
116+
let oid = self
117+
.inner
118+
.peel_to_id_packed(&self.repo.refs, &self.repo.objects, packed)?;
119+
Ok(Id::from_id(oid, self.repo))
120+
}
121+
106122
/// Similar to [`peel_to_id()`](Reference::peel_to_id()), but consumes this instance.
107123
pub fn into_fully_peeled_id(mut self) -> Result<Id<'repo>, peel::Error> {
108124
self.peel_to_id()
@@ -112,7 +128,7 @@ impl<'repo> Reference<'repo> {
112128
/// its type matches the given `kind`. It's an error to try to peel to a kind that this ref doesn't point to.
113129
///
114130
/// Note that this ref will point to the first target object afterward, which may be a tag. This is different
115-
/// from [`peel_to_id_in_place()`](Self::peel_to_id_in_place()) where it will point to the first non-tag object.
131+
/// from [`peel_to_id()`](Self::peel_to_id()) where it will point to the first non-tag object.
116132
///
117133
/// Note that `git2::Reference::peel` does not "peel in place", but returns a new object
118134
/// instead.

0 commit comments

Comments
 (0)