1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2025-08-24 19:39:16 +02:00

Use external diff command in stashes panel

This was forgotten in 6266e19623.
This commit is contained in:
Stefan Haller
2025-08-19 08:35:37 +02:00
parent 0f785c434a
commit 89d50fa229
2 changed files with 19 additions and 4 deletions

View File

@@ -81,11 +81,15 @@ func (self *StashCommands) Hash(index int) (string, error) {
} }
func (self *StashCommands) ShowStashEntryCmdObj(index int) *oscommands.CmdObj { func (self *StashCommands) ShowStashEntryCmdObj(index int) *oscommands.CmdObj {
extDiffCmd := self.UserConfig().Git.Paging.ExternalDiffCommand
// "-u" is the same as "--include-untracked", but the latter fails in older git versions for some reason // "-u" is the same as "--include-untracked", but the latter fails in older git versions for some reason
cmdArgs := NewGitCmd("stash").Arg("show"). cmdArgs := NewGitCmd("stash").Arg("show").
Arg("-p"). Arg("-p").
Arg("--stat"). Arg("--stat").
Arg("-u"). Arg("-u").
ConfigIf(extDiffCmd != "", "diff.external="+extDiffCmd).
ArgIfElse(extDiffCmd != "", "--ext-diff", "--no-ext-diff").
Arg(fmt.Sprintf("--color=%s", self.UserConfig().Git.Paging.ColorArg)). Arg(fmt.Sprintf("--color=%s", self.UserConfig().Git.Paging.ColorArg)).
Arg(fmt.Sprintf("--unified=%d", self.UserConfig().Git.DiffContextSize)). Arg(fmt.Sprintf("--unified=%d", self.UserConfig().Git.DiffContextSize)).
ArgIf(self.UserConfig().Git.IgnoreWhitespaceInDiffView, "--ignore-all-space"). ArgIf(self.UserConfig().Git.IgnoreWhitespaceInDiffView, "--ignore-all-space").

View File

@@ -103,6 +103,7 @@ func TestStashStashEntryCmdObj(t *testing.T) {
contextSize uint64 contextSize uint64
similarityThreshold int similarityThreshold int
ignoreWhitespace bool ignoreWhitespace bool
extDiffCmd string
expected []string expected []string
} }
@@ -113,7 +114,7 @@ func TestStashStashEntryCmdObj(t *testing.T) {
contextSize: 3, contextSize: 3,
similarityThreshold: 50, similarityThreshold: 50,
ignoreWhitespace: false, ignoreWhitespace: false,
expected: []string{"git", "-C", "/path/to/worktree", "stash", "show", "-p", "--stat", "-u", "--color=always", "--unified=3", "--find-renames=50%", "refs/stash@{5}"}, expected: []string{"git", "-C", "/path/to/worktree", "stash", "show", "-p", "--stat", "-u", "--no-ext-diff", "--color=always", "--unified=3", "--find-renames=50%", "refs/stash@{5}"},
}, },
{ {
testName: "Show diff with custom context size", testName: "Show diff with custom context size",
@@ -121,7 +122,7 @@ func TestStashStashEntryCmdObj(t *testing.T) {
contextSize: 77, contextSize: 77,
similarityThreshold: 50, similarityThreshold: 50,
ignoreWhitespace: false, ignoreWhitespace: false,
expected: []string{"git", "-C", "/path/to/worktree", "stash", "show", "-p", "--stat", "-u", "--color=always", "--unified=77", "--find-renames=50%", "refs/stash@{5}"}, expected: []string{"git", "-C", "/path/to/worktree", "stash", "show", "-p", "--stat", "-u", "--no-ext-diff", "--color=always", "--unified=77", "--find-renames=50%", "refs/stash@{5}"},
}, },
{ {
testName: "Show diff with custom similarity threshold", testName: "Show diff with custom similarity threshold",
@@ -129,7 +130,16 @@ func TestStashStashEntryCmdObj(t *testing.T) {
contextSize: 3, contextSize: 3,
similarityThreshold: 33, similarityThreshold: 33,
ignoreWhitespace: false, ignoreWhitespace: false,
expected: []string{"git", "-C", "/path/to/worktree", "stash", "show", "-p", "--stat", "-u", "--color=always", "--unified=3", "--find-renames=33%", "refs/stash@{5}"}, expected: []string{"git", "-C", "/path/to/worktree", "stash", "show", "-p", "--stat", "-u", "--no-ext-diff", "--color=always", "--unified=3", "--find-renames=33%", "refs/stash@{5}"},
},
{
testName: "Show diff with external diff command",
index: 5,
contextSize: 3,
similarityThreshold: 50,
ignoreWhitespace: false,
extDiffCmd: "difft --color=always",
expected: []string{"git", "-C", "/path/to/worktree", "-c", "diff.external=difft --color=always", "stash", "show", "-p", "--stat", "-u", "--ext-diff", "--color=always", "--unified=3", "--find-renames=50%", "refs/stash@{5}"},
}, },
{ {
testName: "Default case", testName: "Default case",
@@ -137,7 +147,7 @@ func TestStashStashEntryCmdObj(t *testing.T) {
contextSize: 3, contextSize: 3,
similarityThreshold: 50, similarityThreshold: 50,
ignoreWhitespace: true, ignoreWhitespace: true,
expected: []string{"git", "-C", "/path/to/worktree", "stash", "show", "-p", "--stat", "-u", "--color=always", "--unified=3", "--ignore-all-space", "--find-renames=50%", "refs/stash@{5}"}, expected: []string{"git", "-C", "/path/to/worktree", "stash", "show", "-p", "--stat", "-u", "--no-ext-diff", "--color=always", "--unified=3", "--ignore-all-space", "--find-renames=50%", "refs/stash@{5}"},
}, },
} }
@@ -147,6 +157,7 @@ func TestStashStashEntryCmdObj(t *testing.T) {
userConfig.Git.IgnoreWhitespaceInDiffView = s.ignoreWhitespace userConfig.Git.IgnoreWhitespaceInDiffView = s.ignoreWhitespace
userConfig.Git.DiffContextSize = s.contextSize userConfig.Git.DiffContextSize = s.contextSize
userConfig.Git.RenameSimilarityThreshold = s.similarityThreshold userConfig.Git.RenameSimilarityThreshold = s.similarityThreshold
userConfig.Git.Paging.ExternalDiffCommand = s.extDiffCmd
repoPaths := RepoPaths{ repoPaths := RepoPaths{
worktreePath: "/path/to/worktree", worktreePath: "/path/to/worktree",
} }