diff options
author | Javi Fontan <jfontan@gmail.com> | 2018-01-24 18:32:16 +0100 |
---|---|---|
committer | Javi Fontan <jfontan@gmail.com> | 2018-01-24 18:38:59 +0100 |
commit | 522327b572276fe94e76ff9bb5e41b1efdf69dee (patch) | |
tree | ed78c69b60e9c6cfb939a712077bd6f32776870c /plumbing/format/packfile/encoder_test.go | |
parent | 834cd6f46fa3a3f2b5423f717cc72769e27c915b (diff) | |
download | go-git-522327b572276fe94e76ff9bb5e41b1efdf69dee.tar.gz |
plumbing: format/packfile, fix crash with cycle deltas
Resolving cycles relied on ObjectToPack objects having Original. This
is no longer true with the changes from #720. This commit changes:
* Save original type, hash and size in ObjectToPack
* Use SetObject to set both Original and resolved type, hash and size
* Restore original object before using BackToOriginal (cycle resolution)
* Update encoder test to check this case
Signed-off-by: Javi Fontan <jfontan@gmail.com>
Diffstat (limited to 'plumbing/format/packfile/encoder_test.go')
-rw-r--r-- | plumbing/format/packfile/encoder_test.go | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/plumbing/format/packfile/encoder_test.go b/plumbing/format/packfile/encoder_test.go index 320036b..06cb1c6 100644 --- a/plumbing/format/packfile/encoder_test.go +++ b/plumbing/format/packfile/encoder_test.go @@ -202,6 +202,15 @@ func (s *EncoderSuite) deltaOverDeltaCyclicTest(c *C) { o3 := newObject(plumbing.BlobObject, []byte("011111")) o4 := newObject(plumbing.BlobObject, []byte("01111100000")) + _, err := s.store.SetEncodedObject(o1) + c.Assert(err, IsNil) + _, err = s.store.SetEncodedObject(o2) + c.Assert(err, IsNil) + _, err = s.store.SetEncodedObject(o3) + c.Assert(err, IsNil) + _, err = s.store.SetEncodedObject(o4) + c.Assert(err, IsNil) + d2, err := GetDelta(o1, o2) c.Assert(err, IsNil) @@ -219,6 +228,18 @@ func (s *EncoderSuite) deltaOverDeltaCyclicTest(c *C) { pd3.SetDelta(pd4, d3) pd4.SetDelta(pd3, d4) + // SetOriginal is used by delta selector when generating ObjectToPack. + // It also fills type, hash and size values to be used when Original + // is nil. + po1.SetOriginal(po1.Original) + pd2.SetOriginal(pd2.Original) + pd2.Original = nil + + pd3.SetOriginal(pd3.Original) + pd3.Original = nil + + pd4.SetOriginal(pd4.Original) + encHash, err := s.enc.encode([]*ObjectToPack{ po1, pd2, |