aboutsummaryrefslogtreecommitdiffstats
path: root/plumbing/object/blob.go
diff options
context:
space:
mode:
Diffstat (limited to 'plumbing/object/blob.go')
-rw-r--r--plumbing/object/blob.go7
1 files changed, 6 insertions, 1 deletions
diff --git a/plumbing/object/blob.go b/plumbing/object/blob.go
index 2771416..2608477 100644
--- a/plumbing/object/blob.go
+++ b/plumbing/object/blob.go
@@ -68,18 +68,23 @@ func (b *Blob) Decode(o plumbing.EncodedObject) error {
// Encode transforms a Blob into a plumbing.EncodedObject.
func (b *Blob) Encode(o plumbing.EncodedObject) error {
+ o.SetType(plumbing.BlobObject)
+
w, err := o.Writer()
if err != nil {
return err
}
+
defer ioutil.CheckClose(w, &err)
+
r, err := b.Reader()
if err != nil {
return err
}
+
defer ioutil.CheckClose(r, &err)
+
_, err = io.Copy(w, r)
- o.SetType(plumbing.BlobObject)
return err
}