diff options
author | Máximo Cuadros <mcuadros@gmail.com> | 2018-04-02 10:39:47 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-04-02 10:39:47 +0200 |
commit | 0c2618bc7d495322c6413b0ff62549712747cf9e (patch) | |
tree | 03ddc67b73733d0582367e9038c454353fa55955 /plumbing/object | |
parent | 160e6d5b654fbbaf0d9264f226c56a03f0e27d30 (diff) | |
parent | 6e07548d9078505ca2945f09d11729b14abcc907 (diff) | |
download | go-git-0c2618bc7d495322c6413b0ff62549712747cf9e.tar.gz |
Merge pull request #794 from jfontan/fix/checkclose
Use CheckClose with named returns and fix tests
Diffstat (limited to 'plumbing/object')
-rw-r--r-- | plumbing/object/blob.go | 2 | ||||
-rw-r--r-- | plumbing/object/commit.go | 2 | ||||
-rw-r--r-- | plumbing/object/file.go | 2 | ||||
-rw-r--r-- | plumbing/object/tag.go | 5 | ||||
-rw-r--r-- | plumbing/object/tree.go | 4 |
5 files changed, 8 insertions, 7 deletions
diff --git a/plumbing/object/blob.go b/plumbing/object/blob.go index 2608477..f376baa 100644 --- a/plumbing/object/blob.go +++ b/plumbing/object/blob.go @@ -67,7 +67,7 @@ func (b *Blob) Decode(o plumbing.EncodedObject) error { } // Encode transforms a Blob into a plumbing.EncodedObject. -func (b *Blob) Encode(o plumbing.EncodedObject) error { +func (b *Blob) Encode(o plumbing.EncodedObject) (err error) { o.SetType(plumbing.BlobObject) w, err := o.Writer() diff --git a/plumbing/object/commit.go b/plumbing/object/commit.go index a317714..c9a4c0e 100644 --- a/plumbing/object/commit.go +++ b/plumbing/object/commit.go @@ -226,7 +226,7 @@ func (b *Commit) Encode(o plumbing.EncodedObject) error { return b.encode(o, true) } -func (b *Commit) encode(o plumbing.EncodedObject, includeSig bool) error { +func (b *Commit) encode(o plumbing.EncodedObject, includeSig bool) (err error) { o.SetType(plumbing.CommitObject) w, err := o.Writer() if err != nil { diff --git a/plumbing/object/file.go b/plumbing/object/file.go index 40b5206..1c5fdbb 100644 --- a/plumbing/object/file.go +++ b/plumbing/object/file.go @@ -44,7 +44,7 @@ func (f *File) Contents() (content string, err error) { } // IsBinary returns if the file is binary or not -func (f *File) IsBinary() (bool, error) { +func (f *File) IsBinary() (bin bool, err error) { reader, err := f.Reader() if err != nil { return false, err diff --git a/plumbing/object/tag.go b/plumbing/object/tag.go index 19e55cf..905206b 100644 --- a/plumbing/object/tag.go +++ b/plumbing/object/tag.go @@ -95,7 +95,8 @@ func (t *Tag) Decode(o plumbing.EncodedObject) (err error) { r := bufio.NewReader(reader) for { - line, err := r.ReadBytes('\n') + var line []byte + line, err = r.ReadBytes('\n') if err != nil && err != io.EOF { return err } @@ -168,7 +169,7 @@ func (t *Tag) Encode(o plumbing.EncodedObject) error { return t.encode(o, true) } -func (t *Tag) encode(o plumbing.EncodedObject, includeSig bool) error { +func (t *Tag) encode(o plumbing.EncodedObject, includeSig bool) (err error) { o.SetType(plumbing.TagObject) w, err := o.Writer() if err != nil { diff --git a/plumbing/object/tree.go b/plumbing/object/tree.go index 2fcd979..c2399f8 100644 --- a/plumbing/object/tree.go +++ b/plumbing/object/tree.go @@ -233,7 +233,7 @@ func (t *Tree) Decode(o plumbing.EncodedObject) (err error) { } // Encode transforms a Tree into a plumbing.EncodedObject. -func (t *Tree) Encode(o plumbing.EncodedObject) error { +func (t *Tree) Encode(o plumbing.EncodedObject) (err error) { o.SetType(plumbing.TreeObject) w, err := o.Writer() if err != nil { @@ -242,7 +242,7 @@ func (t *Tree) Encode(o plumbing.EncodedObject) error { defer ioutil.CheckClose(w, &err) for _, entry := range t.Entries { - if _, err := fmt.Fprintf(w, "%o %s", entry.Mode, entry.Name); err != nil { + if _, err = fmt.Fprintf(w, "%o %s", entry.Mode, entry.Name); err != nil { return err } |