summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJesse Duffield <jessedduffield@gmail.com>2020-07-19 12:19:50 +1000
committerJesse Duffield <jessedduffield@gmail.com>2020-07-19 14:11:32 +1000
commit7d5fe4b66c908cdd55487ee40ddb461efe333f11 (patch)
tree9f02cc3c279c20f03f7ff2c59c31985c6b8a70b6
parent845c80721f8f0445b0abe39ee381a6feecf158a2 (diff)
better logic for staging a renamed file
-rw-r--r--pkg/commands/git.go4
1 files changed, 3 insertions, 1 deletions
diff --git a/pkg/commands/git.go b/pkg/commands/git.go
index 0e4fa2aec..784dad087 100644
--- a/pkg/commands/git.go
+++ b/pkg/commands/git.go
@@ -509,7 +509,9 @@ func (c *GitCommand) CatFile(fileName string) (string, error) {
// StageFile stages a file
func (c *GitCommand) StageFile(fileName string) error {
- return c.OSCommand.RunCommand("git add %s", c.OSCommand.Quote(fileName))
+ // renamed files look like "file1 -> file2"
+ fileNames := strings.Split(fileName, " -> ")
+ return c.OSCommand.RunCommand("git add %s", c.OSCommand.Quote(fileNames[len(fileNames)-1]))
}
// StageAll stages all files