@@ -26,29 +26,64 @@ pub trait ReferenceExt: Sealed {
2626 ///
2727 /// This is useful to learn where this reference is ultimately pointing to after following all symbolic
2828 /// refs and all annotated tags to the first non-tag object.
29+ #[ deprecated = "Use `peel_to_id()` instead" ]
2930 fn peel_to_id_in_place (
3031 & mut self ,
3132 store : & file:: Store ,
3233 objects : & dyn gix_object:: Find ,
3334 ) -> Result < ObjectId , peel:: to_id:: Error > ;
3435
36+ /// Follow all symbolic targets this reference might point to and peel the underlying object
37+ /// to the end of the tag-chain, returning the first non-tag object the annotated tag points to,
38+ /// using `objects` to access them and `store` to lookup symbolic references.
39+ ///
40+ /// This is useful to learn where this reference is ultimately pointing to after following all symbolic
41+ /// refs and all annotated tags to the first non-tag object.
42+ ///
43+ /// Note that this method mutates `self` in place if it does not already point to a
44+ /// non-symbolic object.
45+ fn peel_to_id (
46+ & mut self ,
47+ store : & file:: Store ,
48+ objects : & dyn gix_object:: Find ,
49+ ) -> Result < ObjectId , peel:: to_id:: Error > ;
50+
3551 /// Like [`ReferenceExt::peel_to_id_in_place()`], but with support for a known stable `packed` buffer
3652 /// to use for resolving symbolic links.
53+ #[ deprecated = "Use `peel_to_id_packed()` instead" ]
3754 fn peel_to_id_in_place_packed (
3855 & mut self ,
3956 store : & file:: Store ,
4057 objects : & dyn gix_object:: Find ,
4158 packed : Option < & packed:: Buffer > ,
4259 ) -> Result < ObjectId , peel:: to_id:: Error > ;
4360
61+ /// Like [`ReferenceExt::peel_to_id_in_place()`], but with support for a known stable `packed` buffer
62+ /// to use for resolving symbolic links.
63+ fn peel_to_id_packed (
64+ & mut self ,
65+ store : & file:: Store ,
66+ objects : & dyn gix_object:: Find ,
67+ packed : Option < & packed:: Buffer > ,
68+ ) -> Result < ObjectId , peel:: to_id:: Error > ;
69+
4470 /// Like [`ReferenceExt::follow()`], but follows all symbolic references while gracefully handling loops,
4571 /// altering this instance in place.
72+ #[ deprecated = "Use `follow_to_object_packed()` instead" ]
4673 fn follow_to_object_in_place_packed (
4774 & mut self ,
4875 store : & file:: Store ,
4976 packed : Option < & packed:: Buffer > ,
5077 ) -> Result < ObjectId , peel:: to_object:: Error > ;
5178
79+ /// Like [`ReferenceExt::follow()`], but follows all symbolic references while gracefully handling loops,
80+ /// altering this instance in place.
81+ fn follow_to_object_packed (
82+ & mut self ,
83+ store : & file:: Store ,
84+ packed : Option < & packed:: Buffer > ,
85+ ) -> Result < ObjectId , peel:: to_object:: Error > ;
86+
5287 /// Follow this symbolic reference one level and return the ref it refers to.
5388 ///
5489 /// Returns `None` if this is not a symbolic reference, hence the leaf of the chain.
@@ -84,28 +119,45 @@ impl ReferenceExt for Reference {
84119 & mut self ,
85120 store : & file:: Store ,
86121 objects : & dyn gix_object:: Find ,
122+ ) -> Result < ObjectId , peel:: to_id:: Error > {
123+ self . peel_to_id ( store, objects)
124+ }
125+
126+ fn peel_to_id (
127+ & mut self ,
128+ store : & file:: Store ,
129+ objects : & dyn gix_object:: Find ,
87130 ) -> Result < ObjectId , peel:: to_id:: Error > {
88131 let packed = store. assure_packed_refs_uptodate ( ) . map_err ( |err| {
89132 peel:: to_id:: Error :: FollowToObject ( peel:: to_object:: Error :: Follow ( file:: find:: existing:: Error :: Find (
90133 file:: find:: Error :: PackedOpen ( err) ,
91134 ) ) )
92135 } ) ?;
93- self . peel_to_id_in_place_packed ( store, objects, packed. as_ref ( ) . map ( |b| & * * * b) )
136+ self . peel_to_id_packed ( store, objects, packed. as_ref ( ) . map ( |b| & * * * b) )
94137 }
95138
96139 fn peel_to_id_in_place_packed (
97140 & mut self ,
98141 store : & file:: Store ,
99142 objects : & dyn gix_object:: Find ,
100143 packed : Option < & packed:: Buffer > ,
144+ ) -> Result < ObjectId , peel:: to_id:: Error > {
145+ self . peel_to_id_packed ( store, objects, packed)
146+ }
147+
148+ fn peel_to_id_packed (
149+ & mut self ,
150+ store : & file:: Store ,
151+ objects : & dyn gix_object:: Find ,
152+ packed : Option < & packed:: Buffer > ,
101153 ) -> Result < ObjectId , peel:: to_id:: Error > {
102154 match self . peeled {
103155 Some ( peeled) => {
104156 self . target = Target :: Object ( peeled. to_owned ( ) ) ;
105157 Ok ( peeled)
106158 }
107159 None => {
108- let mut oid = self . follow_to_object_in_place_packed ( store, packed) ?;
160+ let mut oid = self . follow_to_object_packed ( store, packed) ?;
109161 let mut buf = Vec :: new ( ) ;
110162 let peeled_id = loop {
111163 let gix_object:: Data { kind, data } =
@@ -138,6 +190,14 @@ impl ReferenceExt for Reference {
138190 & mut self ,
139191 store : & file:: Store ,
140192 packed : Option < & packed:: Buffer > ,
193+ ) -> Result < ObjectId , peel:: to_object:: Error > {
194+ self . follow_to_object_packed ( store, packed)
195+ }
196+
197+ fn follow_to_object_packed (
198+ & mut self ,
199+ store : & file:: Store ,
200+ packed : Option < & packed:: Buffer > ,
141201 ) -> Result < ObjectId , peel:: to_object:: Error > {
142202 match self . target {
143203 Target :: Object ( id) => Ok ( id) ,
0 commit comments