File tree Expand file tree Collapse file tree 4 files changed +34
-13
lines changed Expand file tree Collapse file tree 4 files changed +34
-13
lines changed Original file line number Diff line number Diff line change @@ -179,8 +179,8 @@ pub mod iter {
179
179
/// Returns the object id of this commits tree if it is the first function called and if there is no error in decoding
180
180
/// the data.
181
181
///
182
- /// Note that this method must only be called once or else will always return None while consuming a single token by calling
183
- /// Errors are coerced into options, hiding whether there was an error or not. THe caller should assume an error if they
182
+ /// Note that this method must only be called once or else will always return None while consuming a single token.
183
+ /// Errors are coerced into options, hiding whether there was an error or not. The caller should assume an error if they
184
184
/// call the method as intended. Such a squelched error cannot be recovered unless the objects data is retrieved and parsed again.
185
185
/// `next()`.
186
186
pub fn tree_id ( & mut self ) -> Option < ObjectId > {
Original file line number Diff line number Diff line change @@ -167,6 +167,17 @@ pub mod iter {
167
167
state : State :: default ( ) ,
168
168
}
169
169
}
170
+
171
+ /// Returns the target id of this tag if it is the first function called and if there is no error in decoding
172
+ /// the data.
173
+ ///
174
+ /// Note that this method must only be called once or else will always return None while consuming a single token.
175
+ /// Errors are coerced into options, hiding whether there was an error or not. The caller should assume an error if they
176
+ /// call the method as intended. Such a squelched error cannot be recovered unless the objects data is retrieved and parsed again.
177
+ /// `next()`.
178
+ pub fn target_id ( & mut self ) -> Option < ObjectId > {
179
+ self . next ( ) . and_then ( Result :: ok) . and_then ( Token :: into_id)
180
+ }
170
181
}
171
182
172
183
impl < ' a > Iter < ' a > {
Original file line number Diff line number Diff line change @@ -214,17 +214,24 @@ where
214
214
break ;
215
215
}
216
216
Commit => {
217
- let tree_id = immutable:: CommitIter :: from_bytes ( obj. data )
217
+ id = immutable:: CommitIter :: from_bytes ( obj. data )
218
218
. tree_id ( )
219
219
. expect ( "every commit has a tree" ) ;
220
- obj = db. find_existing ( tree_id, buf1, cache) . map_err ( |_| Error :: NotFound {
221
- oid : tree_id. to_owned ( ) ,
222
- } ) ?;
223
- id = tree_id;
220
+ obj = db
221
+ . find_existing ( id, buf1, cache)
222
+ . map_err ( |_| Error :: NotFound { oid : id. to_owned ( ) } ) ?;
224
223
continue ;
225
224
}
226
225
Blob => break ,
227
- Tag => todo ! ( "expand tag objects (here and in other places)" ) ,
226
+ Tag => {
227
+ id = immutable:: TagIter :: from_bytes ( obj. data )
228
+ . target_id ( )
229
+ . expect ( "every tag has a target" ) ;
230
+ obj = db
231
+ . find_existing ( id, buf1, cache)
232
+ . map_err ( |_| Error :: NotFound { oid : id. to_owned ( ) } ) ?;
233
+ continue ;
234
+ }
228
235
}
229
236
}
230
237
}
Original file line number Diff line number Diff line change @@ -66,25 +66,27 @@ mod entries {
66
66
trees : usize ,
67
67
commits : usize ,
68
68
blobs : usize ,
69
+ tags : usize ,
69
70
}
70
71
impl Count {
71
72
fn total ( & self ) -> usize {
72
- self . trees + self . commits + self . blobs
73
+ self . tags + self . trees + self . commits + self . blobs
73
74
}
74
75
fn add ( & mut self , kind : git_object:: Kind ) {
75
76
use git_object:: Kind :: * ;
76
77
match kind {
77
78
Tree => self . trees += 1 ,
78
79
Commit => self . commits += 1 ,
79
80
Blob => self . blobs += 1 ,
80
- Tag => unreachable ! ( " tags are not in our test repository" ) ,
81
+ Tag => self . tags += 1 ,
81
82
}
82
83
}
83
84
}
84
85
let whole_pack = Count {
85
- trees : 39 ,
86
- commits : 15 ,
87
- blobs : 810 ,
86
+ trees : 40 ,
87
+ commits : 16 ,
88
+ blobs : 811 ,
89
+ tags : 1 ,
88
90
} ;
89
91
for ( expansion_mode, expected_count) in [
90
92
(
@@ -93,6 +95,7 @@ mod entries {
93
95
trees : 0 ,
94
96
commits : 15 ,
95
97
blobs : 0 ,
98
+ tags : 1 ,
96
99
} ,
97
100
) ,
98
101
( output:: objects_to_entries:: ObjectExpansion :: TreeContents , whole_pack) ,
You can’t perform that action at this time.
0 commit comments