@@ -7,8 +7,8 @@ use crate::{
77mod error {
88 use crate :: { object, reference} ;
99
10- /// The error returned by [`Head::peel_to_id_in_place ()`](super::Head::try_peel_to_id_in_place ())
11- /// and [`Head::into_fully_peeled_id()`](super::Head::try_into_peeled_id()).
10+ /// The error returned by [`Head::peel_to_id ()`](super::Head::try_peel_to_id ()) and
11+ /// [`Head::into_fully_peeled_id()`](super::Head::try_into_peeled_id()).
1212 #[ derive( Debug , thiserror:: Error ) ]
1313 #[ allow( missing_docs) ]
1414 pub enum Error {
@@ -42,7 +42,7 @@ pub mod into_id {
4242pub mod to_commit {
4343 use crate :: object;
4444
45- /// The error returned by [`Head::peel_to_commit_in_place ()`](super::Head::peel_to_commit_in_place ()).
45+ /// The error returned by [`Head::peel_to_commit ()`](super::Head::peel_to_commit ()).
4646 #[ derive( Debug , thiserror:: Error ) ]
4747 #[ allow( missing_docs) ]
4848 pub enum Error {
@@ -55,7 +55,7 @@ pub mod to_commit {
5555
5656///
5757pub mod to_object {
58- /// The error returned by [`Head::peel_to_object_in_place ()`](super::Head::peel_to_object_in_place ()).
58+ /// The error returned by [`Head::peel_to_object ()`](super::Head::peel_to_object ()).
5959 #[ derive( Debug , thiserror:: Error ) ]
6060 #[ allow( missing_docs) ]
6161 pub enum Error {
@@ -72,7 +72,7 @@ impl<'repo> Head<'repo> {
7272 /// The final target is obtained by following symbolic references and peeling tags to their final destination, which
7373 /// typically is a commit, but can be any object.
7474 pub fn into_peeled_id ( mut self ) -> Result < crate :: Id < ' repo > , into_id:: Error > {
75- self . try_peel_to_id_in_place ( ) ?;
75+ self . try_peel_to_id ( ) ?;
7676 self . id ( ) . ok_or_else ( || match self . kind {
7777 Kind :: Symbolic ( gix_ref:: Reference { name, .. } ) | Kind :: Unborn ( name) => into_id:: Error :: Unborn { name } ,
7878 Kind :: Detached { .. } => unreachable ! ( "id can be returned after peeling" ) ,
@@ -84,7 +84,7 @@ impl<'repo> Head<'repo> {
8484 /// The final target is obtained by following symbolic references and peeling tags to their final destination, which
8585 /// typically is a commit, but can be any object as well.
8686 pub fn into_peeled_object ( mut self ) -> Result < crate :: Object < ' repo > , to_object:: Error > {
87- self . peel_to_object_in_place ( )
87+ self . peel_to_object ( )
8888 }
8989
9090 /// Consume this instance and transform it into the final object that it points to, or `Ok(None)` if the `HEAD`
@@ -93,7 +93,7 @@ impl<'repo> Head<'repo> {
9393 /// The final target is obtained by following symbolic references and peeling tags to their final destination, which
9494 /// typically is a commit, but can be any object.
9595 pub fn try_into_peeled_id ( mut self ) -> Result < Option < crate :: Id < ' repo > > , Error > {
96- self . try_peel_to_id_in_place ( )
96+ self . try_peel_to_id ( )
9797 }
9898
9999 /// Follow the symbolic reference of this head until its target object and peel it by following tag objects until there is no
@@ -103,7 +103,21 @@ impl<'repo> Head<'repo> {
103103 ///
104104 /// The final target is obtained by following symbolic references and peeling tags to their final destination, which
105105 /// typically is a commit, but can be any object.
106+ #[ deprecated = "Use `try_peel_to_id()` instead" ]
106107 pub fn try_peel_to_id_in_place ( & mut self ) -> Result < Option < crate :: Id < ' repo > > , Error > {
108+ self . try_peel_to_id ( )
109+ }
110+
111+ /// Follow the symbolic reference of this head until its target object and peel it by following tag objects until there is no
112+ /// more object to follow, and return that object id.
113+ ///
114+ /// Returns `Ok(None)` if the head is unborn.
115+ ///
116+ /// The final target is obtained by following symbolic references and peeling tags to their final destination, which
117+ /// typically is a commit, but can be any object.
118+ ///
119+ /// Note that this method mutates `self` in place.
120+ pub fn try_peel_to_id ( & mut self ) -> Result < Option < crate :: Id < ' repo > > , Error > {
107121 Ok ( Some ( match & mut self . kind {
108122 Kind :: Unborn ( _name) => return Ok ( None ) ,
109123 Kind :: Detached {
@@ -139,12 +153,21 @@ impl<'repo> Head<'repo> {
139153 /// more object to follow, transform the id into a commit if possible and return that.
140154 ///
141155 /// Returns an error if the head is unborn or if it doesn't point to a commit.
156+ #[ deprecated = "Use `peel_to_object()` instead" ]
142157 pub fn peel_to_object_in_place ( & mut self ) -> Result < crate :: Object < ' repo > , to_object:: Error > {
143- let id = self
144- . try_peel_to_id_in_place ( ) ?
145- . ok_or_else ( || to_object:: Error :: Unborn {
146- name : self . referent_name ( ) . expect ( "unborn" ) . to_owned ( ) ,
147- } ) ?;
158+ self . peel_to_object ( )
159+ }
160+
161+ /// Follow the symbolic reference of this head until its target object and peel it by following tag objects until there is no
162+ /// more object to follow, transform the id into a commit if possible and return that.
163+ ///
164+ /// Returns an error if the head is unborn or if it doesn't point to a commit.
165+ ///
166+ /// Note that this method mutates `self` in place.
167+ pub fn peel_to_object ( & mut self ) -> Result < crate :: Object < ' repo > , to_object:: Error > {
168+ let id = self . try_peel_to_id ( ) ?. ok_or_else ( || to_object:: Error :: Unborn {
169+ name : self . referent_name ( ) . expect ( "unborn" ) . to_owned ( ) ,
170+ } ) ?;
148171 id. object ( )
149172 . map_err ( |err| to_object:: Error :: Peel ( Error :: FindExistingObject ( err) ) )
150173 }
@@ -153,7 +176,18 @@ impl<'repo> Head<'repo> {
153176 /// more object to follow, transform the id into a commit if possible and return that.
154177 ///
155178 /// Returns an error if the head is unborn or if it doesn't point to a commit.
179+ #[ deprecated = "Use `peel_to_commit()` instead" ]
156180 pub fn peel_to_commit_in_place ( & mut self ) -> Result < crate :: Commit < ' repo > , to_commit:: Error > {
157- Ok ( self . peel_to_object_in_place ( ) ?. try_into_commit ( ) ?)
181+ self . peel_to_commit ( )
182+ }
183+
184+ /// Follow the symbolic reference of this head until its target object and peel it by following tag objects until there is no
185+ /// more object to follow, transform the id into a commit if possible and return that.
186+ ///
187+ /// Returns an error if the head is unborn or if it doesn't point to a commit.
188+ ///
189+ /// Note that this method mutates `self` in place.
190+ pub fn peel_to_commit ( & mut self ) -> Result < crate :: Commit < ' repo > , to_commit:: Error > {
191+ Ok ( self . peel_to_object ( ) ?. try_into_commit ( ) ?)
158192 }
159193}
0 commit comments