aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--options.go6
-rw-r--r--plumbing/storer/storer.go6
-rw-r--r--repository.go6
-rw-r--r--repository_test.go7
-rw-r--r--storage/filesystem/dotgit/dotgit.go17
-rw-r--r--storage/filesystem/storage.go25
-rw-r--r--storage/filesystem/storage_test.go4
7 files changed, 33 insertions, 38 deletions
diff --git a/options.go b/options.go
index 7b55146..f67a454 100644
--- a/options.go
+++ b/options.go
@@ -9,6 +9,7 @@ import (
"gopkg.in/src-d/go-git.v4/plumbing"
"gopkg.in/src-d/go-git.v4/plumbing/object"
"gopkg.in/src-d/go-git.v4/plumbing/protocol/packp/sideband"
+ "gopkg.in/src-d/go-git.v4/plumbing/storer"
"gopkg.in/src-d/go-git.v4/plumbing/transport"
)
@@ -428,11 +429,12 @@ func (o *GrepOptions) Validate(w *Worktree) error {
// PlainOpenOptions describes how opening a plain repository should be
// performed.
type PlainOpenOptions struct {
+ // Storage layer options.
+ Storage storer.Options
+
// DetectDotGit defines whether parent directories should be
// walked until a .git directory or file is found.
DetectDotGit bool
- // Static means that the repository won't be modified while open.
- Static bool
}
// Validate validates the fields and sets the default values.
diff --git a/plumbing/storer/storer.go b/plumbing/storer/storer.go
index c7bc65a..1b7d226 100644
--- a/plumbing/storer/storer.go
+++ b/plumbing/storer/storer.go
@@ -13,3 +13,9 @@ type Initializer interface {
// any.
Init() error
}
+
+// Options holds configuration for the storage.
+type Options struct {
+ // Static means that the filesystem is not modified while the repo is open.
+ Static bool
+}
diff --git a/repository.go b/repository.go
index d99d6eb..4ad5252 100644
--- a/repository.go
+++ b/repository.go
@@ -251,11 +251,7 @@ func PlainOpenWithOptions(path string, o *PlainOpenOptions) (*Repository, error)
return nil, err
}
- so := filesystem.StorageOptions{
- Static: o.Static,
- }
-
- s, err := filesystem.NewStorageWithOptions(dot, so)
+ s, err := filesystem.NewStorageWithOptions(dot, o.Storage)
if err != nil {
return nil, err
}
diff --git a/repository_test.go b/repository_test.go
index b891413..8956a9d 100644
--- a/repository_test.go
+++ b/repository_test.go
@@ -559,14 +559,17 @@ func (s *RepositorySuite) TestPlainOpenStatic(c *C) {
c.Assert(err, IsNil)
c.Assert(r, NotNil)
- op := &PlainOpenOptions{Static: true}
+ op := &PlainOpenOptions{
+ Storage: storer.Options{Static: true},
+ }
+
r, err = PlainOpenWithOptions(dir, op)
c.Assert(err, IsNil)
c.Assert(r, NotNil)
sto, ok := r.Storer.(*filesystem.Storage)
c.Assert(ok, Equals, true)
- c.Assert(sto.StorageOptions.Static, Equals, true)
+ c.Assert(sto.Options.Static, Equals, true)
}
func (s *RepositorySuite) TestPlainClone(c *C) {
diff --git a/storage/filesystem/dotgit/dotgit.go b/storage/filesystem/dotgit/dotgit.go
index 2048ddc..41e5c75 100644
--- a/storage/filesystem/dotgit/dotgit.go
+++ b/storage/filesystem/dotgit/dotgit.go
@@ -14,6 +14,7 @@ import (
"gopkg.in/src-d/go-billy.v4/osfs"
"gopkg.in/src-d/go-git.v4/plumbing"
+ "gopkg.in/src-d/go-git.v4/plumbing/storer"
"gopkg.in/src-d/go-git.v4/utils/ioutil"
"gopkg.in/src-d/go-billy.v4"
@@ -60,7 +61,7 @@ var (
// The DotGit type represents a local git repository on disk. This
// type is not zero-value-safe, use the New function to initialize it.
type DotGit struct {
- DotGitOptions
+ storer.Options
fs billy.Filesystem
// incoming object directory information
@@ -73,25 +74,19 @@ type DotGit struct {
packMap map[plumbing.Hash]struct{}
}
-// DotGitOptions holds configuration options for new DotGit objects.
-type DotGitOptions struct {
- // Static means that the filesystem won't be changed while the repo is open.
- Static bool
-}
-
// New returns a DotGit value ready to be used. The path argument must
// be the absolute path of a git repository directory (e.g.
// "/foo/bar/.git").
func New(fs billy.Filesystem) *DotGit {
- return NewWithOptions(fs, DotGitOptions{})
+ return NewWithOptions(fs, storer.Options{})
}
// NewWithOptions creates a new DotGit and sets non default configuration
// options. See New for complete help.
-func NewWithOptions(fs billy.Filesystem, o DotGitOptions) *DotGit {
+func NewWithOptions(fs billy.Filesystem, o storer.Options) *DotGit {
return &DotGit{
- DotGitOptions: o,
- fs: fs,
+ Options: o,
+ fs: fs,
}
}
diff --git a/storage/filesystem/storage.go b/storage/filesystem/storage.go
index a969a1f..24e6454 100644
--- a/storage/filesystem/storage.go
+++ b/storage/filesystem/storage.go
@@ -2,6 +2,7 @@
package filesystem
import (
+ "gopkg.in/src-d/go-git.v4/plumbing/storer"
"gopkg.in/src-d/go-git.v4/storage/filesystem/dotgit"
"gopkg.in/src-d/go-billy.v4"
@@ -11,7 +12,7 @@ import (
// 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 {
- StorageOptions
+ storer.Options
fs billy.Filesystem
dir *dotgit.DotGit
@@ -24,36 +25,26 @@ type Storage struct {
ModuleStorage
}
-// StorageOptions holds configuration for the storage.
-type StorageOptions struct {
- // Static means that the filesystem is not modified while the repo is open.
- Static bool
-}
-
// NewStorage returns a new Storage backed by a given `fs.Filesystem`
func NewStorage(fs billy.Filesystem) (*Storage, error) {
- return NewStorageWithOptions(fs, StorageOptions{})
+ return NewStorageWithOptions(fs, storer.Options{})
}
// NewStorageWithOptions returns a new Storage backed by a given `fs.Filesystem`
func NewStorageWithOptions(
fs billy.Filesystem,
- ops StorageOptions,
+ ops storer.Options,
) (*Storage, error) {
- dOps := dotgit.DotGitOptions{
- Static: ops.Static,
- }
-
- dir := dotgit.NewWithOptions(fs, dOps)
+ dir := dotgit.NewWithOptions(fs, ops)
o, err := NewObjectStorage(dir)
if err != nil {
return nil, err
}
return &Storage{
- StorageOptions: ops,
- fs: fs,
- dir: dir,
+ Options: ops,
+ fs: fs,
+ dir: dir,
ObjectStorage: o,
ReferenceStorage: ReferenceStorage{dir: dir},
diff --git a/storage/filesystem/storage_test.go b/storage/filesystem/storage_test.go
index d7ebf71..23628c7 100644
--- a/storage/filesystem/storage_test.go
+++ b/storage/filesystem/storage_test.go
@@ -64,7 +64,9 @@ var _ = Suite(&StorageStaticSuite{})
func (s *StorageStaticSuite) SetUpTest(c *C) {
s.dir = c.MkDir()
- storage, err := NewStorageWithOptions(osfs.New(s.dir), StorageOptions{Static: true})
+ storage, err := NewStorageWithOptions(
+ osfs.New(s.dir),
+ storer.Options{Static: true})
c.Assert(err, IsNil)
setUpTest(&s.StorageSuite, c, storage)