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

Commit b0e21ee

Browse files
committed
Better fix for the getObjectType problem in the iterator
Signed-off-by: Filip Navara <[email protected]>
1 parent 20ccd73 commit b0e21ee

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

plumbing/format/packfile/packfile.go

+9-6
Original file line numberDiff line numberDiff line change
@@ -488,18 +488,21 @@ func (i *objectIter) Next() (plumbing.EncodedObject, error) {
488488
}
489489

490490
if h.Type == plumbing.REFDeltaObject || h.Type == plumbing.OFSDeltaObject {
491-
obj, err := i.p.getNextObject(h, e.Hash)
491+
typ, err := i.p.getObjectType(h)
492492
if err != nil {
493493
return nil, err
494494
}
495-
if obj.Type() == i.typ {
496-
return obj, nil
495+
if typ != i.typ {
496+
continue
497+
}
498+
// getObjectType will seek in the file so we cannot use getNextObject safely
499+
return i.p.objectAtOffset(int64(e.Offset), e.Hash)
500+
} else {
501+
if h.Type != i.typ {
502+
continue
497503
}
498-
} else if h.Type == i.typ {
499504
return i.p.getNextObject(h, e.Hash)
500505
}
501-
502-
continue
503506
}
504507
}
505508

0 commit comments

Comments
 (0)