From 2e092f909f643ef455d84dfa59282f0f0adf3c7a Mon Sep 17 00:00:00 2001 From: Máximo Cuadros Date: Wed, 3 May 2017 23:37:21 +0200 Subject: worktree: Status return empty status instead of nil --- worktree_status.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'worktree_status.go') diff --git a/worktree_status.go b/worktree_status.go index 46922da..f78a0c2 100644 --- a/worktree_status.go +++ b/worktree_status.go @@ -4,6 +4,8 @@ import ( "bytes" "io" + "fmt" + "gopkg.in/src-d/go-git.v4/plumbing" "gopkg.in/src-d/go-git.v4/plumbing/filemode" "gopkg.in/src-d/go-git.v4/plumbing/format/index" @@ -19,7 +21,7 @@ import ( func (w *Worktree) Status() (Status, error) { ref, err := w.r.Head() if err == plumbing.ErrReferenceNotFound { - return nil, nil + return make(Status, 0), nil } if err != nil { @@ -177,7 +179,9 @@ func (w *Worktree) Add(path string) (plumbing.Hash, error) { return h, err } - if s.File(path).Worktree == Unmodified { + fmt.Println(len(s)) + fs := s.File(path) + if fs != nil && fs.Worktree == Unmodified { return h, nil } -- cgit