aboutsummaryrefslogtreecommitdiffstats
path: root/storage/filesystem/storage.go
diff options
context:
space:
mode:
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
}