Get returns the object with the given hash, by searching for it in the packfile.
(h plumbing.Hash, canBeDelta bool)
| 451 | // Get returns the object with the given hash, by searching for it in |
| 452 | // the packfile. |
| 453 | func (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 | |
| 482 | func (s *ObjectStorage) decodeObjectAt( |
| 483 | p *packfile.Packfile, |