From 7d5fe4b66c908cdd55487ee40ddb461efe333f11 Mon Sep 17 00:00:00 2001 From: Jesse Duffield <jessedduffield@gmail.com> Date: Sun, 19 Jul 2020 12:19:50 +1000 Subject: [PATCH] better logic for staging a renamed file --- pkg/commands/git.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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