From b0e21ee09bde46ab5002c04680885890390d3cf7 Mon Sep 17 00:00:00 2001 From: Filip Navara Date: Wed, 24 Apr 2019 09:30:00 +0200 Subject: Better fix for the getObjectType problem in the iterator Signed-off-by: Filip Navara --- plumbing/format/packfile/packfile.go | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'plumbing') diff --git a/plumbing/format/packfile/packfile.go b/plumbing/format/packfile/packfile.go index d4e6010..a8f3d2b 100644 --- a/plumbing/format/packfile/packfile.go +++ b/plumbing/format/packfile/packfile.go @@ -488,18 +488,21 @@ func (i *objectIter) Next() (plumbing.EncodedObject, error) { } if h.Type == plumbing.REFDeltaObject || h.Type == plumbing.OFSDeltaObject { - obj, err := i.p.getNextObject(h, e.Hash) + typ, err := i.p.getObjectType(h) if err != nil { return nil, err } - if obj.Type() == i.typ { - return obj, nil + if typ != i.typ { + continue + } + // getObjectType will seek in the file so we cannot use getNextObject safely + return i.p.objectAtOffset(int64(e.Offset), e.Hash) + } else { + if h.Type != i.typ { + continue } - } else if h.Type == i.typ { return i.p.getNextObject(h, e.Hash) } - - continue } } -- cgit