diff options
author | Ryooooooga <eial5q265e5@gmail.com> | 2022-04-05 23:35:41 +0900 |
---|---|---|
committer | Jesse Duffield <jessedduffield@gmail.com> | 2022-04-06 08:26:13 +1000 |
commit | 53257db99d10bd533c134714b76965041c56cd19 (patch) | |
tree | 422d58d742ae82f8a5e2b4c4d3464915462adc7a /pkg/commands | |
parent | 954d1a814793012d3a22d99e5570f6c369fff1b1 (diff) |
fix: fix diff of renamed files
Diffstat (limited to 'pkg/commands')
-rw-r--r-- | pkg/commands/git_commands/working_tree.go | 6 | ||||
-rw-r--r-- | pkg/commands/models/file.go | 5 |
2 files changed, 10 insertions, 1 deletions
diff --git a/pkg/commands/git_commands/working_tree.go b/pkg/commands/git_commands/working_tree.go index d9aecf01f..cac93385a 100644 --- a/pkg/commands/git_commands/working_tree.go +++ b/pkg/commands/git_commands/working_tree.go @@ -230,6 +230,7 @@ func (self *WorkingTreeCommands) WorktreeFileDiffCmdObj(node models.IFile, plain trackedArg := "--" colorArg := self.UserConfig.Git.Paging.ColorArg quotedPath := self.cmd.Quote(node.GetPath()) + quotedPrevPath := "" ignoreWhitespaceArg := "" contextSize := self.UserConfig.Git.DiffContextSize if cached { @@ -244,8 +245,11 @@ func (self *WorkingTreeCommands) WorktreeFileDiffCmdObj(node models.IFile, plain if ignoreWhitespace { ignoreWhitespaceArg = " --ignore-all-space" } + if prevPath := node.GetPreviousPath(); prevPath != "" { + quotedPrevPath = " " + self.cmd.Quote(prevPath) + } - cmdStr := fmt.Sprintf("git diff --submodule --no-ext-diff --unified=%d --color=%s%s%s %s %s", contextSize, colorArg, ignoreWhitespaceArg, cachedArg, trackedArg, quotedPath) + cmdStr := fmt.Sprintf("git diff --submodule --no-ext-diff --unified=%d --color=%s%s%s %s %s%s", contextSize, colorArg, ignoreWhitespaceArg, cachedArg, trackedArg, quotedPath, quotedPrevPath) return self.cmd.New(cmdStr).DontLog() } diff --git a/pkg/commands/models/file.go b/pkg/commands/models/file.go index c5e76949a..bfb40ee53 100644 --- a/pkg/commands/models/file.go +++ b/pkg/commands/models/file.go @@ -27,6 +27,7 @@ type IFile interface { GetHasStagedChanges() bool GetIsTracked() bool GetPath() string + GetPreviousPath() string } func (f *File) IsRename() bool { @@ -85,3 +86,7 @@ func (f *File) GetPath() string { // TODO: remove concept of name; just use path return f.Name } + +func (f *File) GetPreviousPath() string { + return f.PreviousName +} |