diff options
Diffstat (limited to 'repository.go')
-rw-r--r-- | repository.go | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/repository.go b/repository.go index 76be660..a3e441b 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 @@ -681,7 +694,7 @@ func (r *Repository) Log(o *LogOptions) (object.CommitIter, error) { return nil, err } - return object.NewCommitPreIterator(commit), nil + return object.NewCommitPreorderIter(commit), nil } // Tags returns all the References from Tags. This method returns all the tag @@ -914,7 +927,7 @@ func (r *Repository) ResolveRevision(rev plumbing.Revision) (*plumbing.Hash, err commit = c } case revision.CaretReg: - history := object.NewCommitPreIterator(commit) + history := object.NewCommitPreorderIter(commit) re := item.(revision.CaretReg).Regexp negate := item.(revision.CaretReg).Negate @@ -944,7 +957,7 @@ func (r *Repository) ResolveRevision(rev plumbing.Revision) (*plumbing.Hash, err commit = c case revision.AtDate: - history := object.NewCommitPreIterator(commit) + history := object.NewCommitPreorderIter(commit) date := item.(revision.AtDate).Date |