aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--blame_test.go2
-rw-r--r--commit.go5
-rw-r--r--commit_test.go8
-rw-r--r--common_test.go2
-rw-r--r--core/reference.go15
-rw-r--r--core/storage.go4
-rw-r--r--examples/object_storage/main.go19
-rw-r--r--examples/object_storage/storage.go127
-rw-r--r--references_test.go2
-rw-r--r--repository.go52
-rw-r--r--storage/filesystem/object_test.go5
-rw-r--r--storage/filesystem/storage.go20
-rw-r--r--storage/memory/storage.go12
-rw-r--r--storage/memory/storage_test.go28
-rw-r--r--tree.go4
-rw-r--r--tree_diff_test.go2
-rw-r--r--utils/difftree/difftree_test.go7
17 files changed, 211 insertions, 103 deletions
diff --git a/blame_test.go b/blame_test.go
index 53a9122..f766831 100644
--- a/blame_test.go
+++ b/blame_test.go
@@ -32,7 +32,7 @@ func (s *BlameCommon) SetUpSuite(c *C) {
stream := packfile.NewStream(bytes.NewReader(data))
d := packfile.NewDecoder(stream)
- err = d.Decode(r.os)
+ err = d.Decode(r.s.ObjectStorage())
c.Assert(err, IsNil)
c.Assert(f.Close(), IsNil)
diff --git a/commit.go b/commit.go
index 6f12a56..96b3147 100644
--- a/commit.go
+++ b/commit.go
@@ -37,7 +37,10 @@ func (c *Commit) Tree() *Tree {
// Parents return a CommitIter to the parent Commits
func (c *Commit) Parents() *CommitIter {
- return NewCommitIter(c.r, core.NewObjectLookupIter(c.r.os, c.parents))
+ return NewCommitIter(c.r, core.NewObjectLookupIter(
+ c.r.s.ObjectStorage(),
+ c.parents,
+ ))
}
// NumParents returns the number of parents in a commit.
diff --git a/commit_test.go b/commit_test.go
index 5d009e0..c9a17c0 100644
--- a/commit_test.go
+++ b/commit_test.go
@@ -42,7 +42,7 @@ var commitIterTests = []struct {
func (s *SuiteCommit) TestIterSlice(c *C) {
for i, t := range commitIterTests {
r := s.repos[t.repo]
- iter := NewCommitIter(r, core.NewObjectSliceIter(makeObjectSlice(t.commits, r.os)))
+ iter := NewCommitIter(r, core.NewObjectSliceIter(makeObjectSlice(t.commits, r.s.ObjectStorage())))
s.checkIter(c, r, i, iter, t.commits)
}
}
@@ -50,7 +50,7 @@ func (s *SuiteCommit) TestIterSlice(c *C) {
func (s *SuiteCommit) TestIterLookup(c *C) {
for i, t := range commitIterTests {
r := s.repos[t.repo]
- iter := NewCommitIter(r, core.NewObjectLookupIter(r.os, makeHashSlice(t.commits)))
+ iter := NewCommitIter(r, core.NewObjectLookupIter(r.s.ObjectStorage(), makeHashSlice(t.commits)))
s.checkIter(c, r, i, iter, t.commits)
}
}
@@ -68,7 +68,7 @@ func (s *SuiteCommit) checkIter(c *C, r *Repository, subtest int, iter *CommitIt
func (s *SuiteCommit) TestIterSliceClose(c *C) {
for i, t := range commitIterTests {
r := s.repos[t.repo]
- iter := NewCommitIter(r, core.NewObjectSliceIter(makeObjectSlice(t.commits, r.os)))
+ iter := NewCommitIter(r, core.NewObjectSliceIter(makeObjectSlice(t.commits, r.s.ObjectStorage())))
s.checkIterClose(c, i, iter)
}
}
@@ -76,7 +76,7 @@ func (s *SuiteCommit) TestIterSliceClose(c *C) {
func (s *SuiteCommit) TestIterLookupClose(c *C) {
for i, t := range commitIterTests {
r := s.repos[t.repo]
- iter := NewCommitIter(r, core.NewObjectLookupIter(r.os, makeHashSlice(t.commits)))
+ iter := NewCommitIter(r, core.NewObjectLookupIter(r.s.ObjectStorage(), makeHashSlice(t.commits)))
s.checkIterClose(c, i, iter)
}
}
diff --git a/common_test.go b/common_test.go
index e0d11b5..cd37e75 100644
--- a/common_test.go
+++ b/common_test.go
@@ -96,7 +96,7 @@ func unpackFixtures(c *C, fixtures ...[]packedFixture) map[string]*Repository {
r := packfile.NewStream(memStream)
d := packfile.NewDecoder(r)
- err = d.Decode(repos[fixture.url].os)
+ err = d.Decode(repos[fixture.url].s.ObjectStorage())
c.Assert(err, IsNil, comment)
c.Assert(f.Close(), IsNil, comment)
diff --git a/core/reference.go b/core/reference.go
index 7d3f378..3ec95a0 100644
--- a/core/reference.go
+++ b/core/reference.go
@@ -132,6 +132,21 @@ func (r *Reference) IsTag() bool {
return strings.HasPrefix(string(r.n), refTagPrefix)
}
+// Strings dump a reference as a [2]string
+func (r *Reference) Strings() [2]string {
+ var o [2]string
+ o[0] = r.Name().String()
+
+ switch r.Type() {
+ case HashReference:
+ o[1] = r.Hash().String()
+ case SymbolicReference:
+ o[1] = symrefPrefix + r.Target().String()
+ }
+
+ return o
+}
+
// ReferenceSliceIter implements ReferenceIter. It iterates over a series of
// references stored in a slice and yields each one in turn when Next() is
// called.
diff --git a/core/storage.go b/core/storage.go
index 70a47e6..cb8f45d 100644
--- a/core/storage.go
+++ b/core/storage.go
@@ -2,8 +2,8 @@ package core
// Storage storage of objects and references
type Storage interface {
- ObjectStorage() (ObjectStorage, error)
- ReferenceStorage() (ReferenceStorage, error)
+ ObjectStorage() ObjectStorage
+ ReferenceStorage() ReferenceStorage
}
// ObjectStorage generic storage of objects
diff --git a/examples/object_storage/main.go b/examples/object_storage/main.go
index 5cba6e6..22fa426 100644
--- a/examples/object_storage/main.go
+++ b/examples/object_storage/main.go
@@ -8,26 +8,25 @@ import (
"github.com/aerospike/aerospike-client-go"
- "gopkg.in/src-d/go-git.v3"
+ "gopkg.in/src-d/go-git.v4"
)
func main() {
url := os.Args[2]
- r, err := git.NewRepository(url, nil)
+ client, err := aerospike.NewClient("127.0.0.1", 3000)
if err != nil {
panic(err)
}
- client, err := aerospike.NewClient("127.0.0.1", 3000)
+ s := NewAerospikeStorage(url, client)
+ r, err := git.NewRepository(s)
if err != nil {
panic(err)
}
- r.Storage = NewAerospikeObjectStorage(url, client)
-
switch os.Args[1] {
- case "pull":
- pull(r)
+ case "clone":
+ clone(r, url)
case "list":
list(r)
default:
@@ -35,11 +34,11 @@ func main() {
}
}
-func pull(r *git.Repository) {
- fmt.Printf("Retrieving %q ...\n", os.Args[2])
+func clone(r *git.Repository, url string) {
+ fmt.Printf("Cloning %q ...\n", os.Args[2])
start := time.Now()
- if err := r.PullDefault(); err != nil {
+ if err := r.Clone(&git.CloneOptions{URL: url}); err != nil {
panic(err)
}
diff --git a/examples/object_storage/storage.go b/examples/object_storage/storage.go
index c1e06a0..5868591 100644
--- a/examples/object_storage/storage.go
+++ b/examples/object_storage/storage.go
@@ -3,9 +3,9 @@ package main
import (
"fmt"
"io"
+ "io/ioutil"
- "gopkg.in/src-d/go-git.v3/core"
- "gopkg.in/src-d/go-git.v3/storage/memory"
+ "gopkg.in/src-d/go-git.v4/core"
"github.com/aerospike/aerospike-client-go"
)
@@ -13,6 +13,33 @@ import (
// CREATE INDEX commits ON test.commit (url) STRING;
// CREATE INDEX blobs ON test.blob (url) STRING;
+type AerospikeStorage struct {
+ url string
+ client *aerospike.Client
+ os *AerospikeObjectStorage
+ rs *AerospikeReferenceStorage
+}
+
+func NewAerospikeStorage(url string, client *aerospike.Client) *AerospikeStorage {
+ return &AerospikeStorage{url: url, client: client}
+}
+
+func (s *AerospikeStorage) ObjectStorage() core.ObjectStorage {
+ if s.os == nil {
+ s.os = NewAerospikeObjectStorage(s.url, s.client)
+ }
+
+ return s.os
+}
+
+func (s *AerospikeStorage) ReferenceStorage() core.ReferenceStorage {
+ if s.rs == nil {
+ s.rs = NewAerospikeReferenceStorage(s.url, s.client)
+ }
+
+ return s.rs
+}
+
type AerospikeObjectStorage struct {
url string
client *aerospike.Client
@@ -22,17 +49,31 @@ func NewAerospikeObjectStorage(url string, c *aerospike.Client) *AerospikeObject
return &AerospikeObjectStorage{url, c}
}
+func (s *AerospikeObjectStorage) NewObject() core.Object {
+ return &core.MemoryObject{}
+}
+
func (o *AerospikeObjectStorage) Set(obj core.Object) (core.Hash, error) {
key, err := aerospike.NewKey("test", obj.Type().String(), obj.Hash().String())
if err != nil {
return obj.Hash(), err
}
+ r, err := obj.Reader()
+ if err != nil {
+ return obj.Hash(), err
+ }
+
+ c, err := ioutil.ReadAll(r)
+ if err != nil {
+ return obj.Hash(), err
+ }
+
bins := aerospike.BinMap{
"url": o.url,
"hash": obj.Hash().String(),
"type": obj.Type().String(),
- "blob": obj.Content(),
+ "blob": c,
}
err = o.client.Put(nil, key, bins)
@@ -83,7 +124,85 @@ func (i *AerospikeObjectIter) Next() (core.Object, error) {
}
content := r.Bins["blob"].([]byte)
- return memory.NewObject(i.t, int64(len(content)), content), nil
+
+ o := &core.MemoryObject{}
+ o.SetType(i.t)
+ o.SetSize(int64(len(content)))
+
+ _, err := o.Write(content)
+ if err != nil {
+ return nil, err
+ }
+
+ return o, nil
}
func (i *AerospikeObjectIter) Close() {}
+
+type AerospikeReferenceStorage struct {
+ url string
+ client *aerospike.Client
+}
+
+func NewAerospikeReferenceStorage(url string, c *aerospike.Client) *AerospikeReferenceStorage {
+ return &AerospikeReferenceStorage{url, c}
+}
+
+// Set stores a reference.
+func (s *AerospikeReferenceStorage) Set(ref *core.Reference) error {
+ key, err := aerospike.NewKey("test", "references", ref.Name().String())
+ if err != nil {
+ return err
+ }
+
+ raw := ref.Strings()
+ bins := aerospike.BinMap{
+ "url": s.url,
+ "name": raw[0],
+ "target": raw[1],
+ }
+
+ return s.client.Put(nil, key, bins)
+}
+
+// Get returns a stored reference with the given name
+func (s *AerospikeReferenceStorage) Get(n core.ReferenceName) (*core.Reference, error) {
+ key, err := aerospike.NewKey("test", "references", n.String())
+ if err != nil {
+ return nil, err
+ }
+
+ rec, err := s.client.Get(nil, key)
+ if err != nil {
+ return nil, err
+ }
+
+ return core.NewReferenceFromStrings(
+ rec.Bins["name"].(string),
+ rec.Bins["target"].(string),
+ ), nil
+}
+
+// Iter returns a core.ReferenceIter
+func (s *AerospikeReferenceStorage) Iter() (core.ReferenceIter, error) {
+ stmnt := aerospike.NewStatement("test", "references")
+ err := stmnt.Addfilter(aerospike.NewEqualFilter("url", s.url))
+ if err != nil {
+ return nil, err
+ }
+
+ rs, err := s.client.Query(nil, stmnt)
+ if err != nil {
+ return nil, err
+ }
+
+ var refs []*core.Reference
+ for r := range rs.Records {
+ refs = append(refs, core.NewReferenceFromStrings(
+ r.Bins["name"].(string),
+ r.Bins["target"].(string),
+ ))
+ }
+
+ return core.NewReferenceSliceIter(refs), nil
+}
diff --git a/references_test.go b/references_test.go
index 68fa6e6..18661db 100644
--- a/references_test.go
+++ b/references_test.go
@@ -28,7 +28,7 @@ func (s *ReferencesSuite) SetUpSuite(c *C) {
c.Assert(err, IsNil)
r := packfile.NewSeekable(f)
d := packfile.NewDecoder(r)
- err = d.Decode(s.repos[fix.url].os)
+ err = d.Decode(s.repos[fix.url].s.ObjectStorage())
c.Assert(err, IsNil)
}
}
diff --git a/repository.go b/repository.go
index 6f2679c..9e34dad 100644
--- a/repository.go
+++ b/repository.go
@@ -23,10 +23,8 @@ const (
// Repository giturl string, auth common.AuthMethod repository struct
type Repository struct {
Remotes map[string]*Remote
- Storage core.Storage
- os core.ObjectStorage
- rs core.ReferenceStorage
+ s core.Storage
}
// NewMemoryRepository creates a new repository, backed by a memory.Storage
@@ -46,21 +44,7 @@ func NewFilesystemRepository(fs fs.FS, path string) (*Repository, error) {
// NewRepository creates a new repository with the given Storage
func NewRepository(s core.Storage) (*Repository, error) {
- os, err := s.ObjectStorage()
- if err != nil {
- return nil, err
- }
-
- rs, err := s.ReferenceStorage()
- if err != nil {
- return nil, err
- }
-
- return &Repository{
- Storage: s,
- os: os,
- rs: rs,
- }, nil
+ return &Repository{s: s}, nil
}
// Clone clones a remote repository
@@ -76,7 +60,7 @@ func (r *Repository) Clone(o *CloneOptions) error {
return err
}
- err = remote.Fetch(r.os, &FetchOptions{ReferenceName: o.ReferenceName})
+ err = remote.Fetch(r.s.ObjectStorage(), &FetchOptions{ReferenceName: o.ReferenceName})
if err != nil {
return err
}
@@ -105,19 +89,21 @@ func (r *Repository) createDefaultRemote(url string, auth common.AuthMethod) (*R
func (r *Repository) createDefaultBranch(ref *core.Reference) error {
if !ref.IsBranch() {
// detached HEAD mode
- return r.rs.Set(core.NewHashReference(core.HEAD, ref.Hash()))
+ head := core.NewHashReference(core.HEAD, ref.Hash())
+ return r.s.ReferenceStorage().Set(head)
}
- if err := r.rs.Set(ref); err != nil {
+ if err := r.s.ReferenceStorage().Set(ref); err != nil {
return err
}
- return r.rs.Set(core.NewSymbolicReference(core.HEAD, ref.Name()))
+ head := core.NewSymbolicReference(core.HEAD, ref.Name())
+ return r.s.ReferenceStorage().Set(head)
}
// Commit return the commit with the given hash
func (r *Repository) Commit(h core.Hash) (*Commit, error) {
- obj, err := r.os.Get(h)
+ obj, err := r.s.ObjectStorage().Get(h)
if err != nil {
if err == core.ErrObjectNotFound {
return nil, ErrObjectNotFound
@@ -131,7 +117,7 @@ func (r *Repository) Commit(h core.Hash) (*Commit, error) {
// Commits decode the objects into commits
func (r *Repository) Commits() (*CommitIter, error) {
- iter, err := r.os.Iter(core.CommitObject)
+ iter, err := r.s.ObjectStorage().Iter(core.CommitObject)
if err != nil {
return nil, err
}
@@ -141,7 +127,7 @@ func (r *Repository) Commits() (*CommitIter, error) {
// Tree return the tree with the given hash
func (r *Repository) Tree(h core.Hash) (*Tree, error) {
- obj, err := r.os.Get(h)
+ obj, err := r.s.ObjectStorage().Get(h)
if err != nil {
if err == core.ErrObjectNotFound {
return nil, ErrObjectNotFound
@@ -155,7 +141,7 @@ func (r *Repository) Tree(h core.Hash) (*Tree, error) {
// Blob returns the blob with the given hash
func (r *Repository) Blob(h core.Hash) (*Blob, error) {
- obj, err := r.os.Get(h)
+ obj, err := r.s.ObjectStorage().Get(h)
if err != nil {
if err == core.ErrObjectNotFound {
return nil, ErrObjectNotFound
@@ -169,7 +155,7 @@ func (r *Repository) Blob(h core.Hash) (*Blob, error) {
// Tag returns a tag with the given hash.
func (r *Repository) Tag(h core.Hash) (*Tag, error) {
- obj, err := r.os.Get(h)
+ obj, err := r.s.ObjectStorage().Get(h)
if err != nil {
if err == core.ErrObjectNotFound {
return nil, ErrObjectNotFound
@@ -184,7 +170,7 @@ func (r *Repository) Tag(h core.Hash) (*Tag, error) {
// Tags returns a TagIter that can step through all of the annotated tags
// in the repository.
func (r *Repository) Tags() (*TagIter, error) {
- iter, err := r.os.Iter(core.TagObject)
+ iter, err := r.s.ObjectStorage().Iter(core.TagObject)
if err != nil {
return nil, err
}
@@ -194,7 +180,7 @@ func (r *Repository) Tags() (*TagIter, error) {
// Object returns an object with the given hash.
func (r *Repository) Object(h core.Hash) (Object, error) {
- obj, err := r.os.Get(h)
+ obj, err := r.s.ObjectStorage().Get(h)
if err != nil {
if err == core.ErrObjectNotFound {
return nil, ErrObjectNotFound
@@ -222,20 +208,20 @@ func (r *Repository) Object(h core.Hash) (Object, error) {
// Head returns the reference where HEAD is pointing
func (r *Repository) Head() (*core.Reference, error) {
- return core.ResolveReference(r.rs, core.HEAD)
+ return core.ResolveReference(r.s.ReferenceStorage(), core.HEAD)
}
// Ref returns the Hash pointing the given refName
func (r *Repository) Ref(name core.ReferenceName, resolved bool) (*core.Reference, error) {
if resolved {
- return core.ResolveReference(r.rs, name)
+ return core.ResolveReference(r.s.ReferenceStorage(), name)
}
- return r.rs.Get(name)
+ return r.s.ReferenceStorage().Get(name)
}
// Refs returns a map with all the References
func (r *Repository) Refs() core.ReferenceIter {
- i, _ := r.rs.Iter()
+ i, _ := r.s.ReferenceStorage().Iter()
return i
}
diff --git a/storage/filesystem/object_test.go b/storage/filesystem/object_test.go
index 5c4c7c8..8bca5c6 100644
--- a/storage/filesystem/object_test.go
+++ b/storage/filesystem/object_test.go
@@ -76,10 +76,7 @@ func (s *FsSuite) newObjectStorage(c *C, fixtureName string) core.ObjectStorage
store, err := NewStorage(fs, fs.Join(path, ".git/"))
c.Assert(err, IsNil)
- obj, err := store.ObjectStorage()
- c.Assert(err, IsNil)
-
- return obj
+ return store.ObjectStorage()
}
func (s *FsSuite) TestGetCompareWithMemoryStorage(c *C) {
diff --git a/storage/filesystem/storage.go b/storage/filesystem/storage.go
index 8f9c555..63d0215 100644
--- a/storage/filesystem/storage.go
+++ b/storage/filesystem/storage.go
@@ -22,25 +22,21 @@ func NewStorage(fs fs.FS, path string) (*Storage, error) {
return &Storage{dir: dir}, nil
}
-func (s *Storage) ObjectStorage() (core.ObjectStorage, error) {
+func (s *Storage) ObjectStorage() core.ObjectStorage {
if s.o != nil {
- return s.o, nil
+ return s.o
}
- i, err := buildIndex(s.dir)
- if err != nil {
- return nil, err
- }
-
- s.o = &ObjectStorage{dir: s.dir, index: i}
- return s.o, nil
+ //TODO: error being ignored
+ i, _ := buildIndex(s.dir)
+ return &ObjectStorage{dir: s.dir, index: i}
}
-func (s *Storage) ReferenceStorage() (core.ReferenceStorage, error) {
+func (s *Storage) ReferenceStorage() core.ReferenceStorage {
if s.r != nil {
- return s.r, nil
+ return s.r
}
s.r = &ReferenceStorage{dir: s.dir}
- return s.r, nil
+ return s.r
}
diff --git a/storage/memory/storage.go b/storage/memory/storage.go
index 9c97523..32c2973 100644
--- a/storage/memory/storage.go
+++ b/storage/memory/storage.go
@@ -20,9 +20,9 @@ func NewStorage() *Storage {
}
// ObjectStorage returns the ObjectStorage if not exists creates a new one
-func (s *Storage) ObjectStorage() (core.ObjectStorage, error) {
+func (s *Storage) ObjectStorage() core.ObjectStorage {
if s.o != nil {
- return s.o, nil
+ return s.o
}
s.o = &ObjectStorage{
@@ -33,19 +33,19 @@ func (s *Storage) ObjectStorage() (core.ObjectStorage, error) {
Tags: make(map[core.Hash]core.Object, 0),
}
- return s.o, nil
+ return s.o
}
// ReferenceStorage returns the ReferenceStorage if not exists creates a new one
-func (s *Storage) ReferenceStorage() (core.ReferenceStorage, error) {
+func (s *Storage) ReferenceStorage() core.ReferenceStorage {
if s.r != nil {
- return s.r, nil
+ return s.r
}
r := make(ReferenceStorage, 0)
s.r = &r
- return s.r, nil
+ return s.r
}
// ObjectStorage is the implementation of core.ObjectStorage for memory.Object
diff --git a/storage/memory/storage_test.go b/storage/memory/storage_test.go
index 8e9a524..ac97584 100644
--- a/storage/memory/storage_test.go
+++ b/storage/memory/storage_test.go
@@ -16,28 +16,23 @@ var _ = Suite(&StorageSuite{})
func (s *StorageSuite) TestStorageObjectStorage(c *C) {
storage := NewStorage()
- o, err := storage.ObjectStorage()
- c.Assert(err, IsNil)
- e, err := storage.ObjectStorage()
- c.Assert(err, IsNil)
+ o := storage.ObjectStorage()
+ e := storage.ObjectStorage()
c.Assert(o == e, Equals, true)
}
func (s *StorageSuite) TestStorageReferenceStorage(c *C) {
storage := NewStorage()
- o, err := storage.ReferenceStorage()
- c.Assert(err, IsNil)
- e, err := storage.ReferenceStorage()
- c.Assert(err, IsNil)
+ o := storage.ReferenceStorage()
+ e := storage.ReferenceStorage()
c.Assert(o == e, Equals, true)
}
func (s *StorageSuite) TestObjectStorageSetAndGet(c *C) {
storage := NewStorage()
- os, err := storage.ObjectStorage()
- c.Assert(err, IsNil)
+ os := storage.ObjectStorage()
commit := &core.MemoryObject{}
commit.SetType(core.CommitObject)
@@ -91,8 +86,7 @@ func (s *StorageSuite) TestObjectStorageIter(c *C) {
tag.SetType(core.TagObject)
storage := NewStorage()
- os, err := storage.ObjectStorage()
- c.Assert(err, IsNil)
+ os := storage.ObjectStorage()
os.Set(commit)
os.Set(tree)
@@ -134,10 +128,9 @@ func (s *StorageSuite) TestObjectStorageIter(c *C) {
func (s *StorageSuite) TestReferenceStorageSetAndGet(c *C) {
storage := NewStorage()
- rs, err := storage.ReferenceStorage()
- c.Assert(err, IsNil)
+ rs := storage.ReferenceStorage()
- err = rs.Set(core.NewReferenceFromStrings("foo", "bc9968d75e48de59f0870ffb71f5e160bbbdcf52"))
+ err := rs.Set(core.NewReferenceFromStrings("foo", "bc9968d75e48de59f0870ffb71f5e160bbbdcf52"))
c.Assert(err, IsNil)
err = rs.Set(core.NewReferenceFromStrings("bar", "482e0eada5de4039e6f216b45b3c9b683b83bfa"))
@@ -150,10 +143,9 @@ func (s *StorageSuite) TestReferenceStorageSetAndGet(c *C) {
func (s *StorageSuite) TestReferenceStorageIter(c *C) {
storage := NewStorage()
- rs, err := storage.ReferenceStorage()
- c.Assert(err, IsNil)
+ rs := storage.ReferenceStorage()
- err = rs.Set(core.NewReferenceFromStrings("foo", "bc9968d75e48de59f0870ffb71f5e160bbbdcf52"))
+ err := rs.Set(core.NewReferenceFromStrings("foo", "bc9968d75e48de59f0870ffb71f5e160bbbdcf52"))
c.Assert(err, IsNil)
i, err := rs.Iter()
diff --git a/tree.go b/tree.go
index 152fc34..d8682d0 100644
--- a/tree.go
+++ b/tree.go
@@ -46,7 +46,7 @@ func (t *Tree) File(path string) (*File, error) {
return nil, ErrFileNotFound
}
- obj, err := t.r.os.Get(e.Hash)
+ obj, err := t.r.s.ObjectStorage().Get(e.Hash)
if err != nil {
if err == core.ErrObjectNotFound {
return nil, ErrFileNotFound // a git submodule
@@ -86,7 +86,7 @@ func (t *Tree) dir(baseName string) (*Tree, error) {
return nil, errDirNotFound
}
- obj, err := t.r.os.Get(entry.Hash)
+ obj, err := t.r.s.ObjectStorage().Get(entry.Hash)
if err != nil {
if err == core.ErrObjectNotFound { // git submodule
return nil, errDirNotFound
diff --git a/tree_diff_test.go b/tree_diff_test.go
index 2217eaa..8e53a4f 100644
--- a/tree_diff_test.go
+++ b/tree_diff_test.go
@@ -46,7 +46,7 @@ func (s *DiffTreeSuite) SetUpSuite(c *C) {
r := packfile.NewSeekable(f)
d := packfile.NewDecoder(r)
- err = d.Decode(s.repos[fixRepo.url].os)
+ err = d.Decode(s.repos[fixRepo.url].s.ObjectStorage())
c.Assert(err, IsNil)
c.Assert(f.Close(), IsNil)
diff --git a/utils/difftree/difftree_test.go b/utils/difftree/difftree_test.go
index b13c228..9f874e4 100644
--- a/utils/difftree/difftree_test.go
+++ b/utils/difftree/difftree_test.go
@@ -8,6 +8,7 @@ import (
"gopkg.in/src-d/go-git.v4"
"gopkg.in/src-d/go-git.v4/core"
"gopkg.in/src-d/go-git.v4/formats/packfile"
+ "gopkg.in/src-d/go-git.v4/storage/memory"
. "gopkg.in/check.v1"
)
@@ -43,7 +44,8 @@ func (s *DiffTreeSuite) SetUpSuite(c *C) {
s.repos = make(map[string]*git.Repository, 0)
for _, fixRepo := range fixtureRepos {
- s.repos[fixRepo.url], _ = git.NewMemoryRepository()
+ store := memory.NewStorage()
+ s.repos[fixRepo.url], _ = git.NewRepository(store)
f, err := os.Open(fixRepo.packfile)
c.Assert(err, IsNil)
@@ -51,8 +53,7 @@ func (s *DiffTreeSuite) SetUpSuite(c *C) {
r := packfile.NewSeekable(f)
d := packfile.NewDecoder(r)
- os, _ := s.repos[fixRepo.url].Storage.ObjectStorage()
- err = d.Decode(os)
+ err = d.Decode(store.ObjectStorage())
c.Assert(err, IsNil)
c.Assert(f.Close(), IsNil)