diff options
author | Santiago M. Mola <santi@mola.io> | 2017-06-05 18:09:57 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-06-05 18:09:57 +0200 |
commit | 2a00316b65585be2bf68e1ea9c0e42c6af4f5679 (patch) | |
tree | bb6699e79ffd57b9141fe9c78300d69a3715885c /repository.go | |
parent | b25c5ead44698a4a036435c8977581ea34f761dd (diff) | |
parent | 88f88ea4cf5d44065edda8b06c2267a9dccea16e (diff) | |
download | go-git-2a00316b65585be2bf68e1ea9c0e42c6af4f5679.tar.gz |
Merge pull request #409 from smola/dirty-plainopen
storage/filesystem: call initialization explicitly, fixes #408
Diffstat (limited to 'repository.go')
-rw-r--r-- | repository.go | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/repository.go b/repository.go index 76be660..35aae52 100644 --- a/repository.go +++ b/repository.go @@ -44,6 +44,10 @@ type Repository struct { // The worktree Filesystem is optional, if nil a bare repository is created. If // the given storer is not empty ErrRepositoryAlreadyExists is returned func Init(s storage.Storer, worktree billy.Filesystem) (*Repository, error) { + if err := initStorer(s); err != nil { + return nil, err + } + r := newRepository(s, worktree) _, err := r.Reference(plumbing.HEAD, false) switch err { @@ -67,6 +71,15 @@ func Init(s storage.Storer, worktree billy.Filesystem) (*Repository, error) { return r, setWorktreeAndStoragePaths(r, worktree) } +func initStorer(s storer.Storer) error { + i, ok := s.(storer.Initializer) + if !ok { + return nil + } + + return i.Init() +} + func setWorktreeAndStoragePaths(r *Repository, worktree billy.Filesystem) error { type fsBased interface { Filesystem() billy.Filesystem |