aboutsummaryrefslogtreecommitdiffstats
path: root/storage/filesystem/storage.go
diff options
context:
space:
mode:
authorMáximo Cuadros <mcuadros@gmail.com>2016-11-07 20:29:58 +0100
committerGitHub <noreply@github.com>2016-11-07 20:29:58 +0100
commit0ff9ef2b44c53e557c78bde0fd9c29847e5f0e23 (patch)
treeb9c7485fe99e6e89fa736ceb0223aeb2ecddb77c /storage/filesystem/storage.go
parentf6ed7424cbf33c7013332d7e95b4262a4bc4a523 (diff)
downloadgo-git-0ff9ef2b44c53e557c78bde0fd9c29847e5f0e23.tar.gz
global storage interface refactor (#112)
* core: ObjectStorage, ReferenceStorage renamed to ObjectStorer and ReferenceStorer * rebase * general, changes request by @alcortes * general, changes request by @alcortes
Diffstat (limited to 'storage/filesystem/storage.go')
-rw-r--r--storage/filesystem/storage.go43
1 files changed, 12 insertions, 31 deletions
diff --git a/storage/filesystem/storage.go b/storage/filesystem/storage.go
index d39d6e4..7e05cd3 100644
--- a/storage/filesystem/storage.go
+++ b/storage/filesystem/storage.go
@@ -2,21 +2,20 @@
package filesystem
import (
- "gopkg.in/src-d/go-git.v4/config"
- "gopkg.in/src-d/go-git.v4/core"
"gopkg.in/src-d/go-git.v4/storage/filesystem/internal/dotgit"
"gopkg.in/src-d/go-git.v4/utils/fs"
)
+// Storage is an implementation of git.Storer that stores data on disk in the
+// standard git format (this is, the .git directory). Zero values of this type
+// are not safe to use, see the NewStorage function below.
type Storage struct {
- dir *dotgit.DotGit
- fs fs.Filesystem
-
- o *ObjectStorage
- r *ReferenceStorage
- c *ConfigStorage
+ ObjectStorage
+ ReferenceStorage
+ ConfigStorage
}
+// NewStorage returns a new Storage backed by a given `fs.Filesystem`
func NewStorage(fs fs.Filesystem) (*Storage, error) {
dir := dotgit.New(fs)
o, err := newObjectStorage(dir)
@@ -24,27 +23,9 @@ func NewStorage(fs fs.Filesystem) (*Storage, error) {
return nil, err
}
- return &Storage{dir: dir, fs: fs, o: o}, nil
-}
-
-func (s *Storage) ObjectStorage() core.ObjectStorage {
- return s.o
-}
-
-func (s *Storage) ReferenceStorage() core.ReferenceStorage {
- if s.r != nil {
- return s.r
- }
-
- s.r = &ReferenceStorage{dir: s.dir}
- return s.r
-}
-
-func (s *Storage) ConfigStorage() config.ConfigStorage {
- if s.c != nil {
- return s.c
- }
-
- s.c = &ConfigStorage{dir: s.dir}
- return s.c
+ return &Storage{
+ ObjectStorage: o,
+ ReferenceStorage: ReferenceStorage{dir: dir},
+ ConfigStorage: ConfigStorage{dir: dir},
+ }, nil
}