@@ -26,29 +26,64 @@ pub trait ReferenceExt: Sealed {
26
26
///
27
27
/// This is useful to learn where this reference is ultimately pointing to after following all symbolic
28
28
/// refs and all annotated tags to the first non-tag object.
29
+ #[ deprecated = "Use `peel_to_id()` instead" ]
29
30
fn peel_to_id_in_place (
30
31
& mut self ,
31
32
store : & file:: Store ,
32
33
objects : & dyn gix_object:: Find ,
33
34
) -> Result < ObjectId , peel:: to_id:: Error > ;
34
35
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
+
35
51
/// Like [`ReferenceExt::peel_to_id_in_place()`], but with support for a known stable `packed` buffer
36
52
/// to use for resolving symbolic links.
53
+ #[ deprecated = "Use `peel_to_id_packed()` instead" ]
37
54
fn peel_to_id_in_place_packed (
38
55
& mut self ,
39
56
store : & file:: Store ,
40
57
objects : & dyn gix_object:: Find ,
41
58
packed : Option < & packed:: Buffer > ,
42
59
) -> Result < ObjectId , peel:: to_id:: Error > ;
43
60
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
+
44
70
/// Like [`ReferenceExt::follow()`], but follows all symbolic references while gracefully handling loops,
45
71
/// altering this instance in place.
72
+ #[ deprecated = "Use `follow_to_object_packed()` instead" ]
46
73
fn follow_to_object_in_place_packed (
47
74
& mut self ,
48
75
store : & file:: Store ,
49
76
packed : Option < & packed:: Buffer > ,
50
77
) -> Result < ObjectId , peel:: to_object:: Error > ;
51
78
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
+
52
87
/// Follow this symbolic reference one level and return the ref it refers to.
53
88
///
54
89
/// Returns `None` if this is not a symbolic reference, hence the leaf of the chain.
@@ -84,28 +119,45 @@ impl ReferenceExt for Reference {
84
119
& mut self ,
85
120
store : & file:: Store ,
86
121
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 ,
87
130
) -> Result < ObjectId , peel:: to_id:: Error > {
88
131
let packed = store. assure_packed_refs_uptodate ( ) . map_err ( |err| {
89
132
peel:: to_id:: Error :: FollowToObject ( peel:: to_object:: Error :: Follow ( file:: find:: existing:: Error :: Find (
90
133
file:: find:: Error :: PackedOpen ( err) ,
91
134
) ) )
92
135
} ) ?;
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) )
94
137
}
95
138
96
139
fn peel_to_id_in_place_packed (
97
140
& mut self ,
98
141
store : & file:: Store ,
99
142
objects : & dyn gix_object:: Find ,
100
143
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 > ,
101
153
) -> Result < ObjectId , peel:: to_id:: Error > {
102
154
match self . peeled {
103
155
Some ( peeled) => {
104
156
self . target = Target :: Object ( peeled. to_owned ( ) ) ;
105
157
Ok ( peeled)
106
158
}
107
159
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) ?;
109
161
let mut buf = Vec :: new ( ) ;
110
162
let peeled_id = loop {
111
163
let gix_object:: Data { kind, data } =
@@ -138,6 +190,14 @@ impl ReferenceExt for Reference {
138
190
& mut self ,
139
191
store : & file:: Store ,
140
192
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 > ,
141
201
) -> Result < ObjectId , peel:: to_object:: Error > {
142
202
match self . target {
143
203
Target :: Object ( id) => Ok ( id) ,
0 commit comments