diff options
Diffstat (limited to 'formats/packfile')
-rw-r--r-- | formats/packfile/decoder.go | 2 | ||||
-rw-r--r-- | formats/packfile/decoder_test.go | 14 |
2 files changed, 15 insertions, 1 deletions
diff --git a/formats/packfile/decoder.go b/formats/packfile/decoder.go index 92c42af..6a0aa71 100644 --- a/formats/packfile/decoder.go +++ b/formats/packfile/decoder.go @@ -188,7 +188,7 @@ func (d *Decoder) recallByOffset(o int64) (core.Object, error) { return d.recallByHash(h) } - return nil, ErrCannotRecall.AddDetails("no object found at offset %d", o) + return d.ReadObjectAt(o) } func (d *Decoder) recallByHash(h core.Hash) (core.Object, error) { diff --git a/formats/packfile/decoder_test.go b/formats/packfile/decoder_test.go index 23fa93a..7baab44 100644 --- a/formats/packfile/decoder_test.go +++ b/formats/packfile/decoder_test.go @@ -83,7 +83,21 @@ func (s *ReaderSuite) TestDecodeCRCs(c *C) { } c.Assert(int(sum), Equals, 78022211966) +} + +func (s *ReaderSuite) TestReadObjectAt(c *C) { + f := fixtures.Basic().One() + + scanner := NewScanner(f.Packfile()) + storage := memory.NewStorage() + + d := NewDecoder(scanner, storage.ObjectStorage()) + // the objects at reference 186, is a delta, so should be recall, without + // being read before. + obj, err := d.ReadObjectAt(186) + c.Assert(err, IsNil) + c.Assert(obj.Hash().String(), Equals, "6ecf0ef2c2dffb796033e5a02219af86ec6584e5") } func AssertObjects(c *C, s *memory.Storage, expects []string) { |