MCPcopy Create free account
hub / github.com/go-git/go-git / getFromPackfile

Method getFromPackfile

storage/filesystem/object.go:453–480  ·  view source on GitHub ↗

Get returns the object with the given hash, by searching for it in the packfile.

(h plumbing.Hash, canBeDelta bool)

Source from the content-addressed store, hash-verified

451// Get returns the object with the given hash, by searching for it in
452// the packfile.
453func (s *ObjectStorage) getFromPackfile(h plumbing.Hash, canBeDelta bool) (
454 plumbing.EncodedObject, error) {
455
456 if err := s.requireIndex(); err != nil {
457 return nil, err
458 }
459
460 pack, hash, offset := s.findObjectInPackfile(h)
461 if offset == -1 {
462 return nil, plumbing.ErrObjectNotFound
463 }
464
465 idx := s.index[pack]
466 p, err := s.packfile(idx, pack)
467 if err != nil {
468 return nil, err
469 }
470
471 if !s.options.KeepDescriptors && s.options.MaxOpenDescriptors == 0 {
472 defer ioutil.CheckClose(p, &err)
473 }
474
475 if canBeDelta {
476 return s.decodeDeltaObjectAt(p, offset, hash)
477 }
478
479 return s.decodeObjectAt(p, offset)
480}
481
482func (s *ObjectStorage) decodeObjectAt(
483 p *packfile.Packfile,

Calls 6

requireIndexMethod · 0.95
findObjectInPackfileMethod · 0.95
packfileMethod · 0.95
decodeDeltaObjectAtMethod · 0.95
decodeObjectAtMethod · 0.95
CheckCloseFunction · 0.92