From 78bab69f9cb3d93b256f13e8b73f223f39d3d670 Mon Sep 17 00:00:00 2001 From: Filip Navara Date: Wed, 24 Apr 2019 09:42:53 +0200 Subject: Populate the offsetToType cache in the iterator even for the skipped objects Signed-off-by: Filip Navara --- plumbing/format/packfile/packfile.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/plumbing/format/packfile/packfile.go b/plumbing/format/packfile/packfile.go index a8f3d2b..def6e99 100644 --- a/plumbing/format/packfile/packfile.go +++ b/plumbing/format/packfile/packfile.go @@ -478,6 +478,7 @@ func (i *objectIter) Next() (plumbing.EncodedObject, error) { } } else if obj, ok := i.p.cacheGet(e.Hash); ok { if obj.Type() != i.typ { + i.p.offsetToType[int64(e.Offset)] = obj.Type() continue } return obj, nil @@ -493,12 +494,14 @@ func (i *objectIter) Next() (plumbing.EncodedObject, error) { return nil, err } if typ != i.typ { + i.p.offsetToType[int64(e.Offset)] = 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 { + i.p.offsetToType[int64(e.Offset)] = h.Type continue } return i.p.getNextObject(h, e.Hash) -- cgit