summaryrefslogtreecommitdiffstats
path: root/pkg/commands/git.go
diff options
context:
space:
mode:
authorJesse Duffield <jessedduffield@gmail.com>2018-08-18 20:14:44 +1000
committerJesse Duffield <jessedduffield@gmail.com>2018-08-18 20:14:44 +1000
commit08666889f41aaf1f5295ef2fd4dba1465f9eed3a (patch)
tree572527759c19d08f0407f5052907a85d29ec574f /pkg/commands/git.go
parent01743755622509c93cbaa0358f8814acd59b00f6 (diff)
improve remove file logic
Diffstat (limited to 'pkg/commands/git.go')
-rw-r--r--pkg/commands/git.go11
1 files changed, 8 insertions, 3 deletions
diff --git a/pkg/commands/git.go b/pkg/commands/git.go
index 3349e4860..94c3c3e1c 100644
--- a/pkg/commands/git.go
+++ b/pkg/commands/git.go
@@ -81,7 +81,7 @@ func (c *GitCommand) GetStatusFiles() []File {
stagedChange := change[0:1]
unstagedChange := statusString[1:2]
filename := statusString[3:]
- tracked := !includes([]string{"??", "A "}, change)
+ tracked := !includes([]string{"??", "A ", "AM"}, change)
file := File{
Name: filename,
DisplayString: statusString,
@@ -358,11 +358,16 @@ func (c *GitCommand) IsInMergeState() (bool, error) {
// RemoveFile directly
func (c *GitCommand) RemoveFile(file File) error {
// if the file isn't tracked, we assume you want to delete it
+ if file.HasStagedChanges {
+ if err := c.OSCommand.RunCommand("git reset -- " + file.Name); err != nil {
+ return err
+ }
+ }
if !file.Tracked {
- return os.RemoveAll(file.Name)
+ return os.RemoveAll(c.OSCommand.Unquote(file.Name))
}
// if the file is tracked, we assume you want to just check it out
- return c.OSCommand.RunCommand("git checkout " + file.Name)
+ return c.OSCommand.RunCommand("git checkout -- " + file.Name)
}
// Checkout checks out a branch, with --force if you set the force arg to true