aboutsummaryrefslogtreecommitdiffstats
path: root/storage
diff options
context:
space:
mode:
authorMáximo Cuadros <mcuadros@gmail.com>2018-04-02 10:39:47 +0200
committerGitHub <noreply@github.com>2018-04-02 10:39:47 +0200
commit0c2618bc7d495322c6413b0ff62549712747cf9e (patch)
tree03ddc67b73733d0582367e9038c454353fa55955 /storage
parent160e6d5b654fbbaf0d9264f226c56a03f0e27d30 (diff)
parent6e07548d9078505ca2945f09d11729b14abcc907 (diff)
downloadgo-git-0c2618bc7d495322c6413b0ff62549712747cf9e.tar.gz
Merge pull request #794 from jfontan/fix/checkclose
Use CheckClose with named returns and fix tests
Diffstat (limited to 'storage')
-rw-r--r--storage/filesystem/config.go8
-rw-r--r--storage/filesystem/index.go4
-rw-r--r--storage/filesystem/internal/dotgit/dotgit.go8
-rw-r--r--storage/filesystem/internal/dotgit/dotgit_setref.go2
-rw-r--r--storage/filesystem/object.go8
5 files changed, 15 insertions, 15 deletions
diff --git a/storage/filesystem/config.go b/storage/filesystem/config.go
index a2cc173..85feaf0 100644
--- a/storage/filesystem/config.go
+++ b/storage/filesystem/config.go
@@ -13,7 +13,7 @@ type ConfigStorage struct {
dir *dotgit.DotGit
}
-func (c *ConfigStorage) Config() (*config.Config, error) {
+func (c *ConfigStorage) Config() (conf *config.Config, err error) {
cfg := config.NewConfig()
f, err := c.dir.Config()
@@ -32,15 +32,15 @@ func (c *ConfigStorage) Config() (*config.Config, error) {
return nil, err
}
- if err := cfg.Unmarshal(b); err != nil {
+ if err = cfg.Unmarshal(b); err != nil {
return nil, err
}
return cfg, err
}
-func (c *ConfigStorage) SetConfig(cfg *config.Config) error {
- if err := cfg.Validate(); err != nil {
+func (c *ConfigStorage) SetConfig(cfg *config.Config) (err error) {
+ if err = cfg.Validate(); err != nil {
return err
}
diff --git a/storage/filesystem/index.go b/storage/filesystem/index.go
index 14ab09a..092edec 100644
--- a/storage/filesystem/index.go
+++ b/storage/filesystem/index.go
@@ -12,7 +12,7 @@ type IndexStorage struct {
dir *dotgit.DotGit
}
-func (s *IndexStorage) SetIndex(idx *index.Index) error {
+func (s *IndexStorage) SetIndex(idx *index.Index) (err error) {
f, err := s.dir.IndexWriter()
if err != nil {
return err
@@ -25,7 +25,7 @@ func (s *IndexStorage) SetIndex(idx *index.Index) error {
return err
}
-func (s *IndexStorage) Index() (*index.Index, error) {
+func (s *IndexStorage) Index() (i *index.Index, err error) {
idx := &index.Index{
Version: 2,
}
diff --git a/storage/filesystem/internal/dotgit/dotgit.go b/storage/filesystem/internal/dotgit/dotgit.go
index 027ef83..6f0f1a5 100644
--- a/storage/filesystem/internal/dotgit/dotgit.go
+++ b/storage/filesystem/internal/dotgit/dotgit.go
@@ -375,7 +375,7 @@ func (d *DotGit) findPackedRefsInFile(f billy.File) ([]*plumbing.Reference, erro
return refs, s.Err()
}
-func (d *DotGit) findPackedRefs() ([]*plumbing.Reference, error) {
+func (d *DotGit) findPackedRefs() (r []*plumbing.Reference, err error) {
f, err := d.fs.Open(packedRefsPath)
if err != nil {
if os.IsNotExist(err) {
@@ -676,7 +676,7 @@ func (d *DotGit) PackRefs() (err error) {
// Gather all refs using addRefsFromRefDir and addRefsFromPackedRefs.
var refs []*plumbing.Reference
seen := make(map[plumbing.ReferenceName]bool)
- if err := d.addRefsFromRefDir(&refs, seen); err != nil {
+ if err = d.addRefsFromRefDir(&refs, seen); err != nil {
return err
}
if len(refs) == 0 {
@@ -684,7 +684,7 @@ func (d *DotGit) PackRefs() (err error) {
return nil
}
numLooseRefs := len(refs)
- if err := d.addRefsFromPackedRefsFile(&refs, f, seen); err != nil {
+ if err = d.addRefsFromPackedRefsFile(&refs, f, seen); err != nil {
return err
}
@@ -701,7 +701,7 @@ func (d *DotGit) PackRefs() (err error) {
w := bufio.NewWriter(tmp)
for _, ref := range refs {
- _, err := w.WriteString(ref.String() + "\n")
+ _, err = w.WriteString(ref.String() + "\n")
if err != nil {
return err
}
diff --git a/storage/filesystem/internal/dotgit/dotgit_setref.go b/storage/filesystem/internal/dotgit/dotgit_setref.go
index c732c9f..d27c1a3 100644
--- a/storage/filesystem/internal/dotgit/dotgit_setref.go
+++ b/storage/filesystem/internal/dotgit/dotgit_setref.go
@@ -9,7 +9,7 @@ import (
"gopkg.in/src-d/go-git.v4/utils/ioutil"
)
-func (d *DotGit) setRef(fileName, content string, old *plumbing.Reference) error {
+func (d *DotGit) setRef(fileName, content string, old *plumbing.Reference) (err error) {
// If we are not checking an old ref, just truncate the file.
mode := os.O_RDWR | os.O_CREATE
if old == nil {
diff --git a/storage/filesystem/object.go b/storage/filesystem/object.go
index 9f1c5ef..26190fd 100644
--- a/storage/filesystem/object.go
+++ b/storage/filesystem/object.go
@@ -55,7 +55,7 @@ func (s *ObjectStorage) requireIndex() error {
return nil
}
-func (s *ObjectStorage) loadIdxFile(h plumbing.Hash) error {
+func (s *ObjectStorage) loadIdxFile(h plumbing.Hash) (err error) {
f, err := s.dir.ObjectPackIdx(h)
if err != nil {
return err
@@ -94,7 +94,7 @@ func (s *ObjectStorage) PackfileWriter() (io.WriteCloser, error) {
}
// SetEncodedObject adds a new object to the storage.
-func (s *ObjectStorage) SetEncodedObject(o plumbing.EncodedObject) (plumbing.Hash, error) {
+func (s *ObjectStorage) SetEncodedObject(o plumbing.EncodedObject) (h plumbing.Hash, err error) {
if o.Type() == plumbing.OFSDeltaObject || o.Type() == plumbing.REFDeltaObject {
return plumbing.ZeroHash, plumbing.ErrInvalidType
}
@@ -113,11 +113,11 @@ func (s *ObjectStorage) SetEncodedObject(o plumbing.EncodedObject) (plumbing.Has
defer ioutil.CheckClose(or, &err)
- if err := ow.WriteHeader(o.Type(), o.Size()); err != nil {
+ if err = ow.WriteHeader(o.Type(), o.Size()); err != nil {
return plumbing.ZeroHash, err
}
- if _, err := io.Copy(ow, or); err != nil {
+ if _, err = io.Copy(ow, or); err != nil {
return plumbing.ZeroHash, err
}