summaryrefslogtreecommitdiffstats
path: root/pkg
diff options
context:
space:
mode:
authorJesse Duffield <jessedduffield@gmail.com>2019-02-20 19:47:01 +1100
committerJesse Duffield Duffield <jesseduffieldduffield@Jesses-MacBook-Pro-3.local>2019-02-24 09:42:32 +1100
commit0173fdb9dfb763a13098be96d1693e19b01db8ca (patch)
treed7cb3c663931efccff9d038749227ee782ba637f /pkg
parent9661ea04f368e5b47d9c624101d7a1804012520b (diff)
support file renames
Diffstat (limited to 'pkg')
-rw-r--r--pkg/commands/git.go13
1 files changed, 11 insertions, 2 deletions
diff --git a/pkg/commands/git.go b/pkg/commands/git.go
index fa6e4c5fe..23cfc2e46 100644
--- a/pkg/commands/git.go
+++ b/pkg/commands/git.go
@@ -387,7 +387,15 @@ func (c *GitCommand) UnStageFile(fileName string, tracked bool) error {
if tracked {
command = "git reset HEAD %s"
}
- return c.OSCommand.RunCommand(fmt.Sprintf(command, c.OSCommand.Quote(fileName)))
+
+ // renamed files look like "file1 -> file2"
+ fileNames := strings.Split(fileName, " -> ")
+ for _, name := range fileNames {
+ if err := c.OSCommand.RunCommand(fmt.Sprintf(command, c.OSCommand.Quote(name))); err != nil {
+ return err
+ }
+ }
+ return nil
}
// GitStatus returns the plaintext short status of the repo
@@ -532,7 +540,8 @@ func (c *GitCommand) Diff(file *File, plain bool) string {
cachedArg := ""
trackedArg := "--"
colorArg := "--color"
- fileName := c.OSCommand.Quote(file.Name)
+ split := strings.Split(file.Name, " -> ") // in case of a renamed file we get the new filename
+ fileName := c.OSCommand.Quote(split[len(split)-1])
if file.HasStagedChanges && !file.HasUnstagedChanges {
cachedArg = "--cached"
}