@@ -65,12 +65,26 @@ impl<'repo> Reference<'repo> {
65
65
/// Peeling
66
66
impl < ' repo > Reference < ' repo > {
67
67
/// 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.
69
69
///
70
70
/// This is useful to learn where this reference is ultimately pointing to after following
71
71
/// the chain of symbolic refs and annotated tags.
72
+ #[ deprecated = "Use `peel_to_id()` instead" ]
72
73
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 ) ?;
74
88
Ok ( Id :: from_id ( oid, self . repo ) )
75
89
}
76
90
@@ -85,20 +99,23 @@ impl<'repo> Reference<'repo> {
85
99
) -> Result < Id < ' repo > , peel:: Error > {
86
100
let oid = self
87
101
. 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) ?;
89
103
Ok ( Id :: from_id ( oid, self . repo ) )
90
104
}
91
105
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.
93
107
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 ( )
95
109
}
96
110
97
111
/// Follow this reference's target until it points at an object directly, and peel that object until
98
112
/// its type matches the given `kind`. It's an error to try to peel to a kind that this ref doesn't point to.
99
113
///
100
114
/// Note that this ref will point to the first target object afterward, which may be a tag. This is different
101
115
/// 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.
102
119
#[ doc( alias = "peel" , alias = "git2" ) ]
103
120
pub fn peel_to_kind ( & mut self , kind : gix_object:: Kind ) -> Result < Object < ' repo > , peel:: to_kind:: Error > {
104
121
let packed = self . repo . refs . cached_packed_buffer ( ) . map_err ( |err| {
@@ -147,7 +164,7 @@ impl<'repo> Reference<'repo> {
147
164
) -> Result < Object < ' repo > , peel:: to_kind:: Error > {
148
165
let target = self
149
166
. inner
150
- . follow_to_object_in_place_packed ( & self . repo . refs , packed) ?
167
+ . follow_to_object_packed ( & self . repo . refs , packed) ?
151
168
. attach ( self . repo ) ;
152
169
Ok ( target. object ( ) ?. peel_to_kind ( kind) ?)
153
170
}
@@ -175,7 +192,7 @@ impl<'repo> Reference<'repo> {
175
192
) -> Result < Id < ' repo > , follow:: to_object:: Error > {
176
193
Ok ( self
177
194
. inner
178
- . follow_to_object_in_place_packed ( & self . repo . refs , packed) ?
195
+ . follow_to_object_packed ( & self . repo . refs , packed) ?
179
196
. attach ( self . repo ) )
180
197
}
181
198
0 commit comments