diff options
Diffstat (limited to 'worktree_status.go')
-rw-r--r-- | worktree_status.go | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/worktree_status.go b/worktree_status.go index 24d0534..36f48eb 100644 --- a/worktree_status.go +++ b/worktree_status.go @@ -39,7 +39,7 @@ func (w *Worktree) Status() (Status, error) { } func (w *Worktree) status(commit plumbing.Hash) (Status, error) { - s := make(Status, 0) + s := make(Status) left, err := w.diffCommitWithStaging(commit, false) if err != nil { @@ -243,7 +243,7 @@ func diffTreeIsEquals(a, b noder.Hasher) bool { } // Add adds the file contents of a file in the worktree to the index. if the -// file is already stagged in the index no error is returned. +// file is already staged in the index no error is returned. func (w *Worktree) Add(path string) (plumbing.Hash, error) { s, err := w.Status() if err != nil { @@ -252,6 +252,9 @@ func (w *Worktree) Add(path string) (plumbing.Hash, error) { h, err := w.copyFileToStorage(path) if err != nil { + if os.IsNotExist(err) { + h, err = w.deleteFromIndex(path) + } return h, err } |