Skip to content
This repository was archived by the owner on Sep 11, 2020. It is now read-only.

Commit 5592dab

Browse files
committed
worktree: Status return untracked for untracked files
1 parent 2e092f9 commit 5592dab

File tree

2 files changed

+5
-6
lines changed

2 files changed

+5
-6
lines changed

worktree_status.go

+4-6
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@ import (
44
"bytes"
55
"io"
66

7-
"fmt"
8-
97
"gopkg.in/src-d/go-git.v4/plumbing"
108
"gopkg.in/src-d/go-git.v4/plumbing/filemode"
119
"gopkg.in/src-d/go-git.v4/plumbing/format/index"
@@ -48,10 +46,13 @@ func (w *Worktree) status(commit plumbing.Hash) (Status, error) {
4846
switch a {
4947
case merkletrie.Delete:
5048
s.File(ch.From.String()).Staging = Deleted
49+
s.File(ch.From.String()).Worktree = Unmodified
5150
case merkletrie.Insert:
5251
s.File(ch.To.String()).Staging = Added
52+
s.File(ch.To.String()).Worktree = Unmodified
5353
case merkletrie.Modify:
5454
s.File(ch.To.String()).Staging = Modified
55+
s.File(ch.To.String()).Worktree = Unmodified
5556
}
5657
}
5758

@@ -71,7 +72,6 @@ func (w *Worktree) status(commit plumbing.Hash) (Status, error) {
7172
s.File(ch.From.String()).Worktree = Deleted
7273
case merkletrie.Insert:
7374
s.File(ch.To.String()).Worktree = Untracked
74-
s.File(ch.To.String()).Staging = Untracked
7575
case merkletrie.Modify:
7676
s.File(ch.To.String()).Worktree = Modified
7777
}
@@ -179,9 +179,7 @@ func (w *Worktree) Add(path string) (plumbing.Hash, error) {
179179
return h, err
180180
}
181181

182-
fmt.Println(len(s))
183-
fs := s.File(path)
184-
if fs != nil && fs.Worktree == Unmodified {
182+
if s.File(path).Worktree == Unmodified {
185183
return h, nil
186184
}
187185

worktree_test.go

+1
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,7 @@ func (s *WorktreeSuite) TestStatus(c *C) {
287287

288288
status, err := w.Status()
289289
c.Assert(err, IsNil)
290+
290291
c.Assert(status.IsClean(), Equals, false)
291292
c.Assert(status, HasLen, 9)
292293
}

0 commit comments

Comments
 (0)