Skip to content
This repository was archived by the owner on Sep 11, 2020. It is now read-only.

Commit 78bab69

Browse files
committed
Populate the offsetToType cache in the iterator even for the skipped objects
Signed-off-by: Filip Navara <[email protected]>
1 parent b0e21ee commit 78bab69

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

plumbing/format/packfile/packfile.go

+3
Original file line numberDiff line numberDiff line change
@@ -478,6 +478,7 @@ func (i *objectIter) Next() (plumbing.EncodedObject, error) {
478478
}
479479
} else if obj, ok := i.p.cacheGet(e.Hash); ok {
480480
if obj.Type() != i.typ {
481+
i.p.offsetToType[int64(e.Offset)] = obj.Type()
481482
continue
482483
}
483484
return obj, nil
@@ -493,12 +494,14 @@ func (i *objectIter) Next() (plumbing.EncodedObject, error) {
493494
return nil, err
494495
}
495496
if typ != i.typ {
497+
i.p.offsetToType[int64(e.Offset)] = typ
496498
continue
497499
}
498500
// getObjectType will seek in the file so we cannot use getNextObject safely
499501
return i.p.objectAtOffset(int64(e.Offset), e.Hash)
500502
} else {
501503
if h.Type != i.typ {
504+
i.p.offsetToType[int64(e.Offset)] = h.Type
502505
continue
503506
}
504507
return i.p.getNextObject(h, e.Hash)

0 commit comments

Comments
 (0)