From eb89d2dd9a36440d58aea224c055b364e49785f7 Mon Sep 17 00:00:00 2001 From: Alberto Cortés Date: Mon, 14 Nov 2016 18:27:31 +0100 Subject: Fix nil tx bug (#124) * add test for non-seekable packfiles * packfile: do not throw away the newly created transactioner --- plumbing/format/packfile/decoder.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'plumbing/format/packfile/decoder.go') diff --git a/plumbing/format/packfile/decoder.go b/plumbing/format/packfile/decoder.go index 470e59b..5c103a0 100644 --- a/plumbing/format/packfile/decoder.go +++ b/plumbing/format/packfile/decoder.go @@ -121,7 +121,7 @@ func (d *Decoder) readObjectsWithObjectStorer(count int) error { } func (d *Decoder) readObjectsWithObjectStorerTx(count int) error { - tx := d.o.(storer.Transactioner).Begin() + d.tx = d.o.(storer.Transactioner).Begin() for i := 0; i < count; i++ { obj, err := d.ReadObject() @@ -129,7 +129,7 @@ func (d *Decoder) readObjectsWithObjectStorerTx(count int) error { return err } - if _, err := tx.SetObject(obj); err != nil { + if _, err := d.tx.SetObject(obj); err != nil { if rerr := d.tx.Rollback(); rerr != nil { return ErrRollback.AddDetails( "error: %s, during tx.Set error: %s", rerr, err, @@ -141,7 +141,7 @@ func (d *Decoder) readObjectsWithObjectStorerTx(count int) error { } - return tx.Commit() + return d.tx.Commit() } // ReadObject reads a object from the stream and return it -- cgit