mirror of
https://github.com/jesseduffield/lazygit.git
synced 2026-09-10 07:36:27 -04:00
Pass the previous path when diffing a filtered directory in the files panel
Restricting the diff to the files that a filter leaves visible drops the delete-side entry of a staged rename, so git shows the file as an addition instead. Its commit files counterpart already passes both paths; this brings the files panel in line.
This commit is contained in:
parent
6913f2afce
commit
2c9187acb9
|
|
@ -650,7 +650,9 @@ func (self *FilesController) pathOverridesForDiff(node *filetree.FileNode) []str
|
|||
if !node.IsFile() && self.context().IsFiltering() {
|
||||
var paths []string
|
||||
_ = node.ForEachFile(func(file *models.File) error {
|
||||
paths = append(paths, file.Path)
|
||||
// For a rename we need to pass both paths so that git detects it as
|
||||
// a rename rather than an unrelated delete and add.
|
||||
paths = append(paths, file.Names()...)
|
||||
return nil
|
||||
})
|
||||
return paths
|
||||
|
|
|
|||
|
|
@ -98,22 +98,11 @@ var DirectoryDiffWithRenamedFiles = NewIntegrationTest(NewIntegrationTestArgs{
|
|||
)
|
||||
|
||||
t.Views().Main().
|
||||
/* EXPECTED:
|
||||
ContainsLines(
|
||||
Equals("diff --git a/file1 b/dir/file1"),
|
||||
Equals("similarity index 100%"),
|
||||
Equals("rename from file1"),
|
||||
Equals("rename to dir/file1"),
|
||||
)
|
||||
ACTUAL: */
|
||||
ContainsLines(
|
||||
Equals("diff --git a/dir/file1 b/dir/file1"),
|
||||
Equals("new file mode 100644"),
|
||||
Contains("index"),
|
||||
Equals("--- /dev/null"),
|
||||
Equals("+++ b/dir/file1"),
|
||||
Equals("@@ -0,0 +1 @@"),
|
||||
Equals("+file1 content"),
|
||||
)
|
||||
},
|
||||
})
|
||||
|
|
|
|||
Loading…
Reference in a new issue