summaryrefslogtreecommitdiffstats
path: root/pkg/commands/loading_files.go
diff options
context:
space:
mode:
authorJesse Duffield <jessedduffield@gmail.com>2021-03-14 13:20:54 +1100
committerJesse Duffield <jessedduffield@gmail.com>2021-03-14 13:24:51 +1100
commit058bcddc53cff6360583cd575fe64da76b53f94b (patch)
tree7081bd4d9ab0f2dc8256a88c0e47c0c70b14bab4 /pkg/commands/loading_files.go
parent8288de0c848d0aeeaf7e33d8038c5f4319c46523 (diff)
fix renamed files looking wrongv0.26.1
Diffstat (limited to 'pkg/commands/loading_files.go')
-rw-r--r--pkg/commands/loading_files.go15
1 files changed, 13 insertions, 2 deletions
diff --git a/pkg/commands/loading_files.go b/pkg/commands/loading_files.go
index a08a45888..2bf77a865 100644
--- a/pkg/commands/loading_files.go
+++ b/pkg/commands/loading_files.go
@@ -77,8 +77,19 @@ func (c *GitCommand) GitStatus(opts GitStatusOptions) (string, error) {
return "", err
}
- statusLines = strings.Replace(statusLines, "\x00", "\n", -1)
- return statusLines, nil
+ splitLines := strings.Split(statusLines, "\x00")
+ // if a line starts with 'R' then the next line is the original file.
+ for i := 0; i < len(splitLines)-1; i++ {
+ original := splitLines[i]
+ if strings.HasPrefix(original, "R ") {
+ next := splitLines[i+1]
+ updated := "R " + next + models.RENAME_SEPARATOR + strings.TrimPrefix(original, "R ")
+ splitLines[i] = updated
+ splitLines = append(splitLines[0:i+1], splitLines[i+2:]...)
+ }
+ }
+
+ return strings.Join(splitLines, "\n"), nil
}
// MergeStatusFiles merge status files