diff options
Diffstat (limited to 'pkg/commands/loading_files.go')
-rw-r--r-- | pkg/commands/loading_files.go | 15 |
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 |