@@ -196,16 +196,16 @@ func (p *Packfile) objectAtOffset(offset int64, hash plumbing.Hash) (plumbing.En
196196 return nil , err
197197 }
198198
199- return p .getNextObjectLazy (h , hash )
199+ return p .getNextObject (h , hash )
200200}
201201
202- func (p * Packfile ) getNextObjectLazy (h * ObjectHeader , hash plumbing.Hash ) (plumbing.EncodedObject , error ) {
202+ func (p * Packfile ) getNextObject (h * ObjectHeader , hash plumbing.Hash ) (plumbing.EncodedObject , error ) {
203203 var err error
204204
205205 // If we have no filesystem, we will return a MemoryObject instead
206206 // of an FSObject.
207207 if p .fs == nil {
208- return p .getNextObject (h )
208+ return p .getNextMemoryObject (h )
209209 }
210210
211211 // If the object is small enough then read it completely into memory now since
@@ -215,7 +215,7 @@ func (p *Packfile) getNextObjectLazy(h *ObjectHeader, hash plumbing.Hash) (plumb
215215 var size int64
216216 if h .Length <= smallObjectThreshold {
217217 if h .Type != plumbing .OFSDeltaObject && h .Type != plumbing .REFDeltaObject {
218- return p .getNextObject (h )
218+ return p .getNextMemoryObject (h )
219219 }
220220
221221 // For delta objects we read the delta data and apply the small object
@@ -284,15 +284,17 @@ func (p *Packfile) getObjectContent(offset int64) (io.ReadCloser, error) {
284284 return nil , err
285285 }
286286
287- obj , err := p .getNextObject (h )
287+ // getObjectContent is called from FSObject, so we have to explicitly
288+ // get memory object here to avoid recursive cycle
289+ obj , err := p .getNextMemoryObject (h )
288290 if err != nil {
289291 return nil , err
290292 }
291293
292294 return obj .Reader ()
293295}
294296
295- func (p * Packfile ) getNextObject (h * ObjectHeader ) (plumbing.EncodedObject , error ) {
297+ func (p * Packfile ) getNextMemoryObject (h * ObjectHeader ) (plumbing.EncodedObject , error ) {
296298 var obj = new (plumbing.MemoryObject )
297299 obj .SetSize (h .Length )
298300 obj .SetType (h .Type )
@@ -498,7 +500,7 @@ func (i *objectIter) Next() (plumbing.EncodedObject, error) {
498500 continue
499501 }
500502
501- return i .p .getNextObjectLazy (h , e .Hash )
503+ return i .p .getNextObject (h , e .Hash )
502504 }
503505 }
504506
0 commit comments