aboutsummaryrefslogtreecommitdiffstats
path: root/storage
diff options
context:
space:
mode:
authorMáximo Cuadros <mcuadros@gmail.com>2016-08-29 23:06:10 +0200
committerMáximo Cuadros <mcuadros@gmail.com>2016-08-29 23:06:10 +0200
commitb73657f1aa7016bdd4c2cbd50bee4c20d5ab69ef (patch)
tree7f93f11b91b84e605a26f573d40791a4f6cb49d0 /storage
parente4246138cb9ffb819c052ba17a9fbdf915427291 (diff)
downloadgo-git-b73657f1aa7016bdd4c2cbd50bee4c20d5ab69ef.tar.gz
core: Storage.Get, switch order of args
Diffstat (limited to 'storage')
-rw-r--r--storage/filesystem/object.go4
-rw-r--r--storage/filesystem/object_test.go4
-rw-r--r--storage/memory/storage.go2
-rw-r--r--storage/test/storage_suite.go9
4 files changed, 10 insertions, 9 deletions
diff --git a/storage/filesystem/object.go b/storage/filesystem/object.go
index 6024ae0..1b1ce9d 100644
--- a/storage/filesystem/object.go
+++ b/storage/filesystem/object.go
@@ -38,7 +38,7 @@ func (s *ObjectStorage) Set(core.Object) (core.Hash, error) {
// Get returns the object with the given hash, by searching for it in
// the packfile.
-func (s *ObjectStorage) Get(h core.Hash, t core.ObjectType) (core.Object, error) {
+func (s *ObjectStorage) Get(t core.ObjectType, h core.Hash) (core.Object, error) {
offset, err := s.index.Get(h)
if err != nil {
return nil, err
@@ -87,7 +87,7 @@ func (s *ObjectStorage) Iter(t core.ObjectType) (core.ObjectIter, error) {
var objects []core.Object
for hash := range s.index {
- object, err := s.Get(hash, core.AnyObject)
+ object, err := s.Get(core.AnyObject, hash)
if err != nil {
return nil, err
}
diff --git a/storage/filesystem/object_test.go b/storage/filesystem/object_test.go
index 956fdeb..361ae32 100644
--- a/storage/filesystem/object_test.go
+++ b/storage/filesystem/object_test.go
@@ -66,7 +66,7 @@ func (s *FsSuite) TestHashNotFound(c *C) {
sto := s.newObjectStorage(c, "binary-relations")
types := []core.ObjectType{core.AnyObject, core.TagObject, core.CommitObject, core.BlobObject, core.TreeObject}
for t := range types {
- _, err := sto.Get(core.ZeroHash, core.ObjectType(t))
+ _, err := sto.Get(core.ObjectType(t), core.ZeroHash)
c.Assert(err, Equals, core.ErrObjectNotFound)
}
}
@@ -158,7 +158,7 @@ func equalsStorages(a, b core.ObjectStorage) (bool, string, error) {
break
}
- bo, err := b.Get(ao.Hash(), core.AnyObject)
+ bo, err := b.Get(core.AnyObject, ao.Hash())
if err != nil {
return false, "", fmt.Errorf("getting object with hash %s: %s",
ao.Hash(), err)
diff --git a/storage/memory/storage.go b/storage/memory/storage.go
index 8033541..fa34c4d 100644
--- a/storage/memory/storage.go
+++ b/storage/memory/storage.go
@@ -130,7 +130,7 @@ func (o *ObjectStorage) Set(obj core.Object) (core.Hash, error) {
}
// Get returns a object with the given hash
-func (o *ObjectStorage) Get(h core.Hash, t core.ObjectType) (core.Object, error) {
+func (o *ObjectStorage) Get(t core.ObjectType, h core.Hash) (core.Object, error) {
obj, ok := o.Objects[h]
if !ok || (core.AnyObject != t && obj.Type() != t) {
return nil, core.ErrObjectNotFound
diff --git a/storage/test/storage_suite.go b/storage/test/storage_suite.go
index 2463d9d..4181e8c 100644
--- a/storage/test/storage_suite.go
+++ b/storage/test/storage_suite.go
@@ -1,9 +1,10 @@
package test
import (
+ "io"
+
. "gopkg.in/check.v1"
"gopkg.in/src-d/go-git.v4/core"
- "io"
)
type TestObject struct {
@@ -38,11 +39,11 @@ func RunObjectStorageSuite(c *C, os core.ObjectStorage) {
c.Assert(err, IsNil)
c.Assert(h.String(), Equals, to.Hash, comment)
- o, err := os.Get(h, to.Type)
+ o, err := os.Get(to.Type, h)
c.Assert(err, IsNil)
c.Assert(o, Equals, to.Object)
- o, err = os.Get(h, core.AnyObject)
+ o, err = os.Get(core.AnyObject, h)
c.Assert(err, IsNil)
c.Assert(o, Equals, to.Object)
@@ -50,7 +51,7 @@ func RunObjectStorageSuite(c *C, os core.ObjectStorage) {
if validType == to.Type {
continue
}
- o, err = os.Get(h, validType)
+ o, err = os.Get(validType, h)
c.Assert(o, IsNil)
c.Assert(err, Equals, core.ErrObjectNotFound)
}