@@ -65,12 +65,26 @@ impl<'repo> Reference<'repo> {
6565/// Peeling
6666impl < ' repo > Reference < ' repo > {
6767 /// Follow all symbolic targets this reference might point to and peel all annotated tags
68- /// to their first non-tag target, and return it,
68+ /// to their first non-tag target, and return it.
6969 ///
7070 /// This is useful to learn where this reference is ultimately pointing to after following
7171 /// the chain of symbolic refs and annotated tags.
72+ #[ deprecated = "Use `peel_to_id()` instead" ]
7273 pub fn peel_to_id_in_place ( & mut self ) -> Result < Id < ' repo > , peel:: Error > {
73- let oid = self . inner . peel_to_id_in_place ( & self . repo . refs , & self . repo . objects ) ?;
74+ let oid = self . inner . peel_to_id ( & self . repo . refs , & self . repo . objects ) ?;
75+ Ok ( Id :: from_id ( oid, self . repo ) )
76+ }
77+
78+ /// Follow all symbolic targets this reference might point to and peel all annotated tags
79+ /// to their first non-tag target, and return it.
80+ ///
81+ /// This is useful to learn where this reference is ultimately pointing to after following
82+ /// the chain of symbolic refs and annotated tags.
83+ ///
84+ /// Note that this method mutates `self` in place if it does not already point to non-symbolic
85+ /// object.
86+ pub fn peel_to_id ( & mut self ) -> Result < Id < ' repo > , peel:: Error > {
87+ let oid = self . inner . peel_to_id ( & self . repo . refs , & self . repo . objects ) ?;
7488 Ok ( Id :: from_id ( oid, self . repo ) )
7589 }
7690
@@ -85,20 +99,23 @@ impl<'repo> Reference<'repo> {
8599 ) -> Result < Id < ' repo > , peel:: Error > {
86100 let oid = self
87101 . inner
88- . peel_to_id_in_place_packed ( & self . repo . refs , & self . repo . objects , packed) ?;
102+ . peel_to_id_packed ( & self . repo . refs , & self . repo . objects , packed) ?;
89103 Ok ( Id :: from_id ( oid, self . repo ) )
90104 }
91105
92- /// Similar to [`peel_to_id_in_place ()`](Reference::peel_to_id_in_place ()), but consumes this instance.
106+ /// Similar to [`peel_to_id ()`](Reference::peel_to_id ()), but consumes this instance.
93107 pub fn into_fully_peeled_id ( mut self ) -> Result < Id < ' repo > , peel:: Error > {
94- self . peel_to_id_in_place ( )
108+ self . peel_to_id ( )
95109 }
96110
97111 /// Follow this reference's target until it points at an object directly, and peel that object until
98112 /// its type matches the given `kind`. It's an error to try to peel to a kind that this ref doesn't point to.
99113 ///
100114 /// Note that this ref will point to the first target object afterward, which may be a tag. This is different
101115 /// from [`peel_to_id_in_place()`](Self::peel_to_id_in_place()) where it will point to the first non-tag object.
116+ ///
117+ /// Note that `git2::Reference::peel` does not "peel in place", but returns a new object
118+ /// instead.
102119 #[ doc( alias = "peel" , alias = "git2" ) ]
103120 pub fn peel_to_kind ( & mut self , kind : gix_object:: Kind ) -> Result < Object < ' repo > , peel:: to_kind:: Error > {
104121 let packed = self . repo . refs . cached_packed_buffer ( ) . map_err ( |err| {
@@ -147,7 +164,7 @@ impl<'repo> Reference<'repo> {
147164 ) -> Result < Object < ' repo > , peel:: to_kind:: Error > {
148165 let target = self
149166 . inner
150- . follow_to_object_in_place_packed ( & self . repo . refs , packed) ?
167+ . follow_to_object_packed ( & self . repo . refs , packed) ?
151168 . attach ( self . repo ) ;
152169 Ok ( target. object ( ) ?. peel_to_kind ( kind) ?)
153170 }
@@ -175,7 +192,7 @@ impl<'repo> Reference<'repo> {
175192 ) -> Result < Id < ' repo > , follow:: to_object:: Error > {
176193 Ok ( self
177194 . inner
178- . follow_to_object_in_place_packed ( & self . repo . refs , packed) ?
195+ . follow_to_object_packed ( & self . repo . refs , packed) ?
179196 . attach ( self . repo ) )
180197 }
181198
0 commit comments