@@ -180,7 +180,7 @@ where
180
180
181
181
fn collect_parents ( & mut self , id : & oid ) -> Result < SmallVec < [ ( ObjectId , GenAndCommitTime ) ; 1 ] > , Error > {
182
182
collect_parents (
183
- self . commit_graph . as_ref ( ) ,
183
+ & mut self . commit_graph ,
184
184
& self . find ,
185
185
id,
186
186
matches ! ( self . parents, Parents :: First ) ,
@@ -193,7 +193,7 @@ where
193
193
& mut self ,
194
194
id : & oid ,
195
195
) -> Result < SmallVec < [ ( ObjectId , GenAndCommitTime ) ; 1 ] > , Error > {
196
- collect_parents ( self . commit_graph . as_ref ( ) , & self . find , id, false , & mut self . buf )
196
+ collect_parents ( & mut self . commit_graph , & self . find , id, false , & mut self . buf )
197
197
}
198
198
199
199
fn pop_commit ( & mut self ) -> Option < Result < Info , Error > > {
@@ -236,7 +236,7 @@ where
236
236
}
237
237
238
238
fn collect_parents < Find > (
239
- cache : Option < & gix_commitgraph:: Graph > ,
239
+ cache : & mut Option < gix_commitgraph:: Graph > ,
240
240
f : Find ,
241
241
id : & oid ,
242
242
first_only : bool ,
@@ -246,7 +246,7 @@ where
246
246
Find : gix_object:: Find ,
247
247
{
248
248
let mut parents = SmallVec :: < [ ( ObjectId , GenAndCommitTime ) ; 1 ] > :: new ( ) ;
249
- match find ( cache, & f, id, buf) ? {
249
+ match find ( cache. as_ref ( ) , & f, id, buf) ? {
250
250
Either :: CommitRefIter ( c) => {
251
251
for token in c {
252
252
use gix_object:: commit:: ref_iter:: Token as T ;
@@ -265,15 +265,21 @@ where
265
265
// Need to check the cache again. That a commit is not in the cache
266
266
// doesn't mean a parent is not.
267
267
for ( id, gen_time) in parents. iter_mut ( ) {
268
- let commit = find ( cache, & f, id, buf) ?;
268
+ let commit = find ( cache. as_ref ( ) , & f, id, buf) ?;
269
269
* gen_time = gen_and_commit_time ( commit) ?;
270
270
}
271
271
}
272
272
Either :: CachedCommit ( c) => {
273
273
for pos in c. iter_parents ( ) {
274
+ let Ok ( pos) = pos else {
275
+ // drop corrupt cache and use ODB from now on.
276
+ * cache = None ;
277
+ return collect_parents ( cache, f, id, first_only, buf) ;
278
+ } ;
274
279
let parent_commit = cache
280
+ . as_ref ( )
275
281
. expect ( "cache exists if CachedCommit was returned" )
276
- . commit_at ( pos? ) ;
282
+ . commit_at ( pos) ;
277
283
parents. push ( (
278
284
parent_commit. id ( ) . into ( ) ,
279
285
( parent_commit. generation ( ) , parent_commit. committer_timestamp ( ) as i64 ) ,
0 commit comments