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/tree.go | |
parent | 5592dabdf9eed67c92b0e411ad375ae763119fd2 (diff) | |
download | go-git-ff18ce3751ad80cfd0297845872ba1d796c36ca5.tar.gz |
plumbing: MemoryObject.Writer tracks his own size
Diffstat (limited to 'plumbing/object/tree.go')
-rw-r--r-- | plumbing/object/tree.go | 14 |
1 files changed, 3 insertions, 11 deletions
diff --git a/plumbing/object/tree.go b/plumbing/object/tree.go index d2265a8..25687b0 100644 --- a/plumbing/object/tree.go +++ b/plumbing/object/tree.go @@ -240,29 +240,21 @@ func (t *Tree) Encode(o plumbing.EncodedObject) error { return err } - var size int defer ioutil.CheckClose(w, &err) for _, entry := range t.Entries { - n, err := fmt.Fprintf(w, "%o %s", entry.Mode, entry.Name) - if err != nil { + if _, err := fmt.Fprintf(w, "%o %s", entry.Mode, entry.Name); err != nil { return err } - size += n - n, err = w.Write([]byte{0x00}) - if err != nil { + if _, err = w.Write([]byte{0x00}); err != nil { return err } - size += n - n, err = w.Write([]byte(entry.Hash[:])) - if err != nil { + if _, err = w.Write([]byte(entry.Hash[:])); err != nil { return err } - size += n } - o.SetSize(int64(size)) return err } |