mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-08-06 22:33:07 +02:00
Fix showing diffs for renamed file when filtering by path
When filtering for a file path we use the --follow option for "git log", so it will follow renames of the file, which is great. However, if you then selected one of the commits before a rename, you didn't see a diff, because we would pass the original filter path to the "git show" call. To fix this, call git log with the --name-status option when filtering by path, so that each commit reports which file paths are touched in this commit; remember these in the commit object, so that we can pass them to the "git show" call later. Be careful not to store too many such paths unnecessarily. When filtering by folder rather than file, all these paths will necessarily be inside the original filter path, so detect this and don't store them in this case. There is some unfortunate code duplication between loading commits and loading reflog commits, which I am too lazy to clean up right now.
This commit is contained in:
@ -80,7 +80,6 @@ var ShowDiffsForRenamedFile = NewIntegrationTest(NewIntegrationTestArgs{
|
||||
t.Views().Main().ContainsLines(
|
||||
Equals(" rename file"),
|
||||
Equals("---"),
|
||||
/* EXPECTED:
|
||||
Equals(" oldFile => newFile | 0"),
|
||||
Equals(" 1 file changed, 0 insertions(+), 0 deletions(-)"),
|
||||
Equals(""),
|
||||
@ -88,24 +87,10 @@ var ShowDiffsForRenamedFile = NewIntegrationTest(NewIntegrationTestArgs{
|
||||
Equals("similarity index 100%"),
|
||||
Equals("rename from oldFile"),
|
||||
Equals("rename to newFile"),
|
||||
ACTUAL: */
|
||||
Equals(" newFile | 3 +++"),
|
||||
Equals(" 1 file changed, 3 insertions(+)"),
|
||||
Equals(""),
|
||||
Equals("diff --git a/newFile b/newFile"),
|
||||
Equals("new file mode 100644"),
|
||||
Contains("index"),
|
||||
Equals("--- /dev/null"),
|
||||
Equals("+++ b/newFile"),
|
||||
Equals("@@ -0,0 +1,3 @@"),
|
||||
Equals("+x"),
|
||||
Equals("+b"),
|
||||
Equals("+c"),
|
||||
)
|
||||
|
||||
t.Views().Commits().SelectNextItem()
|
||||
|
||||
/* EXPECTED:
|
||||
t.Views().Main().ContainsLines(
|
||||
Equals(" update old file"),
|
||||
Equals("---"),
|
||||
@ -122,7 +107,5 @@ var ShowDiffsForRenamedFile = NewIntegrationTest(NewIntegrationTestArgs{
|
||||
Equals(" b"),
|
||||
Equals(" c"),
|
||||
)
|
||||
ACTUAL: */
|
||||
t.Views().Main().IsEmpty()
|
||||
},
|
||||
})
|
||||
|
Reference in New Issue
Block a user