1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2025-04-27 12:32:37 +02:00

support file renames

This commit is contained in:
Jesse Duffield 2019-02-20 19:47:01 +11:00 committed by Jesse Duffield Duffield
parent 9661ea04f3
commit 0173fdb9df

View File

@ -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"
}