Get returns the object with the given hash, by searching for it in the packfile.
(h plumbing.Hash, canBeDelta bool)
| 462 | // Get returns the object with the given hash, by searching for it in |
| 463 | // the packfile. |
| 464 | func (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 | |
| 493 | func (s *ObjectStorage) decodeObjectAt( |
| 494 | p *packfile.Packfile, |