diff options
author | Máximo Cuadros <mcuadros@gmail.com> | 2017-05-04 01:45:11 +0200 |
---|---|---|
committer | Máximo Cuadros <mcuadros@gmail.com> | 2017-05-04 01:45:11 +0200 |
commit | ff18ce3751ad80cfd0297845872ba1d796c36ca5 (patch) | |
tree | 0b0a72f26482bc61bad7258d10a9a2d1392d2b90 /plumbing/object/commit.go | |
parent | 5592dabdf9eed67c92b0e411ad375ae763119fd2 (diff) | |
download | go-git-ff18ce3751ad80cfd0297845872ba1d796c36ca5.tar.gz |
plumbing: MemoryObject.Writer tracks his own size
Diffstat (limited to 'plumbing/object/commit.go')
-rw-r--r-- | plumbing/object/commit.go | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/plumbing/object/commit.go b/plumbing/object/commit.go index 2e47a2a..adac4f9 100644 --- a/plumbing/object/commit.go +++ b/plumbing/object/commit.go @@ -171,30 +171,39 @@ func (b *Commit) Encode(o plumbing.EncodedObject) error { if err != nil { return err } + defer ioutil.CheckClose(w, &err) + if _, err = fmt.Fprintf(w, "tree %s\n", b.TreeHash.String()); err != nil { return err } + for _, parent := range b.ParentHashes { if _, err = fmt.Fprintf(w, "parent %s\n", parent.String()); err != nil { return err } } + if _, err = fmt.Fprint(w, "author "); err != nil { return err } + if err = b.Author.Encode(w); err != nil { return err } + if _, err = fmt.Fprint(w, "\ncommitter "); err != nil { return err } + if err = b.Committer.Encode(w); err != nil { return err } + if _, err = fmt.Fprintf(w, "\n\n%s", b.Message); err != nil { return err } + return err } |