diff options
author | Filip Navara <navara@emclient.com> | 2019-04-24 09:30:00 +0200 |
---|---|---|
committer | Filip Navara <navara@emclient.com> | 2019-04-24 09:30:00 +0200 |
commit | b0e21ee09bde46ab5002c04680885890390d3cf7 (patch) | |
tree | 0e11be076e10c024b4bbc7712282ed623595f1c9 /plumbing | |
parent | 20ccd734ba1a38498d268226a3aa2e5f5f80d757 (diff) | |
download | go-git-b0e21ee09bde46ab5002c04680885890390d3cf7.tar.gz |
Better fix for the getObjectType problem in the iterator
Signed-off-by: Filip Navara <navara@emclient.com>
Diffstat (limited to 'plumbing')
-rw-r--r-- | plumbing/format/packfile/packfile.go | 15 |
1 files changed, 9 insertions, 6 deletions
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 } } |