aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--repository.go12
-rw-r--r--repository_test.go13
2 files changed, 6 insertions, 19 deletions
diff --git a/repository.go b/repository.go
index c49042f..82ebb0c 100644
--- a/repository.go
+++ b/repository.go
@@ -472,7 +472,7 @@ func (r *Repository) updateWorktree() error {
return nil
}
- w, err := r.Worktree(nil)
+ w, err := r.Worktree()
if err != nil {
return err
}
@@ -625,14 +625,10 @@ func (r *Repository) References() (storer.ReferenceIter, error) {
// Worktree returns a worktree based on the given fs, if nil the default
// worktree will be used.
-func (r *Repository) Worktree(fs billy.Filesystem) (*Worktree, error) {
- if r.wt == nil && fs == nil {
+func (r *Repository) Worktree() (*Worktree, error) {
+ if r.wt == nil {
return nil, ErrIsBareRepository
}
- if fs == nil {
- fs = r.wt
- }
-
- return &Worktree{r: r, fs: fs}, nil
+ return &Worktree{r: r, fs: r.wt}, nil
}
diff --git a/repository_test.go b/repository_test.go
index 95cf12f..ead0aa1 100644
--- a/repository_test.go
+++ b/repository_test.go
@@ -747,23 +747,14 @@ func (s *RepositorySuite) TestObjectNotFound(c *C) {
func (s *RepositorySuite) TestWorktree(c *C) {
def := memoryfs.New()
r, _ := Init(memory.NewStorage(), def)
- w, err := r.Worktree(nil)
+ w, err := r.Worktree()
c.Assert(err, IsNil)
c.Assert(w.fs, Equals, def)
}
-func (s *RepositorySuite) TestWorktreeAlternative(c *C) {
- r, _ := Init(memory.NewStorage(), memoryfs.New())
-
- alt := memoryfs.New()
- w, err := r.Worktree(alt)
- c.Assert(err, IsNil)
- c.Assert(w.fs, Equals, alt)
-}
-
func (s *RepositorySuite) TestWorktreeBare(c *C) {
r, _ := Init(memory.NewStorage(), nil)
- w, err := r.Worktree(nil)
+ w, err := r.Worktree()
c.Assert(err, Equals, ErrIsBareRepository)
c.Assert(w, IsNil)
}