aboutsummaryrefslogtreecommitdiffstats
path: root/commit.go
diff options
context:
space:
mode:
Diffstat (limited to 'commit.go')
-rw-r--r--commit.go11
1 files changed, 9 insertions, 2 deletions
diff --git a/commit.go b/commit.go
index 492a928..4b7d918 100644
--- a/commit.go
+++ b/commit.go
@@ -50,13 +50,20 @@ func (c *Commit) File(path string) (file *File, err error) {
}
// Decode transform an core.Object into a Blob struct
-func (c *Commit) Decode(o core.Object) error {
+func (c *Commit) Decode(o core.Object) (err error) {
if o.Type() != core.CommitObject {
return ErrUnsupportedObject
}
c.Hash = o.Hash()
- r := bufio.NewReader(o.Reader())
+
+ reader, err := o.Reader()
+ if err != nil {
+ return err
+ }
+ defer close(reader, &err)
+
+ r := bufio.NewReader(reader)
var message bool
for {