aboutsummaryrefslogtreecommitdiffstats
path: root/worktree_status.go
diff options
context:
space:
mode:
authorMáximo Cuadros <mcuadros@gmail.com>2017-05-03 23:37:21 +0200
committerMáximo Cuadros <mcuadros@gmail.com>2017-05-03 23:37:21 +0200
commit2e092f909f643ef455d84dfa59282f0f0adf3c7a (patch)
tree30f68b00e059945e084c7836ae49c8233a8b4be3 /worktree_status.go
parent9a807f4f29c24bf0dc0b44d7cdfc2233cfd128d3 (diff)
downloadgo-git-2e092f909f643ef455d84dfa59282f0f0adf3c7a.tar.gz
worktree: Status return empty status instead of nil
Diffstat (limited to 'worktree_status.go')
-rw-r--r--worktree_status.go8
1 files changed, 6 insertions, 2 deletions
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
}