MCPcopy Index your code
hub / github.com/go-git/go-git / getFromPackfile

Method getFromPackfile

storage/filesystem/object.go:464–491  ·  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

462// Get returns the object with the given hash, by searching for it in
463// the packfile.
464func (s *ObjectStorage) getFromPackfile(h plumbing.Hash, canBeDelta bool) (
465 plumbing.EncodedObject, error,
466) {
467 if err := s.requireIndex(); err != nil {
468 return nil, err
469 }
470
471 pack, hash, offset := s.findObjectInPackfile(h)
472 if offset == -1 {
473 return nil, plumbing.ErrObjectNotFound
474 }
475
476 idx := s.index[pack]
477 p, err := s.packfile(idx, pack)
478 if err != nil {
479 return nil, err
480 }
481
482 if !s.options.KeepDescriptors && s.options.MaxOpenDescriptors == 0 {
483 defer ioutil.CheckClose(p, &err)
484 }
485
486 if canBeDelta {
487 return s.decodeDeltaObjectAt(p, offset, hash)
488 }
489
490 return s.decodeObjectAt(p, offset)
491}
492
493func (s *ObjectStorage) decodeObjectAt(
494 p *packfile.Packfile,

Calls 6

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