@@ -7,8 +7,8 @@ use crate::{
7
7
mod error {
8
8
use crate :: { object, reference} ;
9
9
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()).
12
12
#[ derive( Debug , thiserror:: Error ) ]
13
13
#[ allow( missing_docs) ]
14
14
pub enum Error {
@@ -42,7 +42,7 @@ pub mod into_id {
42
42
pub mod to_commit {
43
43
use crate :: object;
44
44
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 ()).
46
46
#[ derive( Debug , thiserror:: Error ) ]
47
47
#[ allow( missing_docs) ]
48
48
pub enum Error {
@@ -55,7 +55,7 @@ pub mod to_commit {
55
55
56
56
///
57
57
pub 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 ()).
59
59
#[ derive( Debug , thiserror:: Error ) ]
60
60
#[ allow( missing_docs) ]
61
61
pub enum Error {
@@ -72,7 +72,7 @@ impl<'repo> Head<'repo> {
72
72
/// The final target is obtained by following symbolic references and peeling tags to their final destination, which
73
73
/// typically is a commit, but can be any object.
74
74
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 ( ) ?;
76
76
self . id ( ) . ok_or_else ( || match self . kind {
77
77
Kind :: Symbolic ( gix_ref:: Reference { name, .. } ) | Kind :: Unborn ( name) => into_id:: Error :: Unborn { name } ,
78
78
Kind :: Detached { .. } => unreachable ! ( "id can be returned after peeling" ) ,
@@ -84,7 +84,7 @@ impl<'repo> Head<'repo> {
84
84
/// The final target is obtained by following symbolic references and peeling tags to their final destination, which
85
85
/// typically is a commit, but can be any object as well.
86
86
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 ( )
88
88
}
89
89
90
90
/// 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> {
93
93
/// The final target is obtained by following symbolic references and peeling tags to their final destination, which
94
94
/// typically is a commit, but can be any object.
95
95
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 ( )
97
97
}
98
98
99
99
/// 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> {
103
103
///
104
104
/// The final target is obtained by following symbolic references and peeling tags to their final destination, which
105
105
/// typically is a commit, but can be any object.
106
+ #[ deprecated = "Use `try_peel_to_id()` instead" ]
106
107
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 > {
107
121
Ok ( Some ( match & mut self . kind {
108
122
Kind :: Unborn ( _name) => return Ok ( None ) ,
109
123
Kind :: Detached {
@@ -139,12 +153,21 @@ impl<'repo> Head<'repo> {
139
153
/// more object to follow, transform the id into a commit if possible and return that.
140
154
///
141
155
/// Returns an error if the head is unborn or if it doesn't point to a commit.
156
+ #[ deprecated = "Use `peel_to_object()` instead" ]
142
157
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
+ } ) ?;
148
171
id. object ( )
149
172
. map_err ( |err| to_object:: Error :: Peel ( Error :: FindExistingObject ( err) ) )
150
173
}
@@ -153,7 +176,18 @@ impl<'repo> Head<'repo> {
153
176
/// more object to follow, transform the id into a commit if possible and return that.
154
177
///
155
178
/// Returns an error if the head is unborn or if it doesn't point to a commit.
179
+ #[ deprecated = "Use `peel_to_commit()` instead" ]
156
180
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 ( ) ?)
158
192
}
159
193
}
0 commit comments