Repository: jesseduffield/lazygit (language: go)

Issue:
Lazygit does not show diff of untracked stashed files
**Describe the bug**
Untracked stashed files are not shown in the main view.

**To Reproduce**
Steps to reproduce the behavior:

1. In a git repository: create a new file
2. Stash the untracked file (`git stash --include-untracked`, or use lazygit with shift+S and "Stash all changes including untracked files")
3. In lazygit, focus the Stash panel
4. The untracked stashed file is not shown in the main view

**Expected behavior**
The untracked stashed file diff is shown in the main view in lazygit.

**Screenshots**

![wrong](https://github.com/user-attachments/assets/81097c71-3764-4467-a960-a87c51921139)
*As it is now: the untracked stashed file is not shown in lazygit*.

![correct](https://github.com/user-attachments/assets/4aafd5f6-5305-4f9b-9068-1570d22e755c)
*As it should be: the untracked stashed file diff is shown in lazygit*. I will open a PR that fixes this as shown in the screenshot.

**Version info:**
Lazygit: `commit=, build date=, build source=unknown, version=unversioned, os=linux, arch=amd64, git version=2.45.2`
Git: `git version 2.45.2`



Discussion / hints:

Fix patch:
diff --git a/pkg/commands/git_commands/stash.go b/pkg/commands/git_commands/stash.go
index e3a91c8874b..10af0cc1cd5 100644
--- a/pkg/commands/git_commands/stash.go
+++ b/pkg/commands/git_commands/stash.go
@@ -81,9 +81,11 @@ func (self *StashCommands) Hash(index int) (string, error) {
 }
 
 func (self *StashCommands) ShowStashEntryCmdObj(index int) oscommands.ICmdObj {
+	// "-u" is the same as "--include-untracked", but the latter fails in older git versions for some reason
 	cmdArgs := NewGitCmd("stash").Arg("show").
 		Arg("-p").
 		Arg("--stat").
+		Arg("-u").
 		Arg(fmt.Sprintf("--color=%s", self.UserConfig().Git.Paging.ColorArg)).
 		Arg(fmt.Sprintf("--unified=%d", self.AppState.DiffContextSize)).
 		ArgIf(self.AppState.IgnoreWhitespaceInDiffView, "--ignore-all-space").


Test patch:
diff --git a/pkg/commands/git_commands/stash_test.go b/pkg/commands/git_commands/stash_test.go
index 874b47a9de8..e1ad1946638 100644
--- a/pkg/commands/git_commands/stash_test.go
+++ b/pkg/commands/git_commands/stash_test.go
@@ -113,7 +113,7 @@ func TestStashStashEntryCmdObj(t *testing.T) {
 			contextSize:         3,
 			similarityThreshold: 50,
 			ignoreWhitespace:    false,
-			expected:            []string{"git", "-C", "/path/to/worktree", "stash", "show", "-p", "--stat", "--color=always", "--unified=3", "--find-renames=50%", "stash@{5}"},
+			expected:            []string{"git", "-C", "/path/to/worktree", "stash", "show", "-p", "--stat", "-u", "--color=always", "--unified=3", "--find-renames=50%", "stash@{5}"},
 		},
 		{
 			testName:            "Show diff with custom context size",
@@ -121,7 +121,7 @@ func TestStashStashEntryCmdObj(t *testing.T) {
 			contextSize:         77,
 			similarityThreshold: 50,
 			ignoreWhitespace:    false,
-			expected:            []string{"git", "-C", "/path/to/worktree", "stash", "show", "-p", "--stat", "--color=always", "--unified=77", "--find-renames=50%", "stash@{5}"},
+			expected:            []string{"git", "-C", "/path/to/worktree", "stash", "show", "-p", "--stat", "-u", "--color=always", "--unified=77", "--find-renames=50%", "stash@{5}"},
 		},
 		{
 			testName:            "Show diff with custom similarity threshold",
@@ -129,7 +129,7 @@ func TestStashStashEntryCmdObj(t *testing.T) {
 			contextSize:         3,
 			similarityThreshold: 33,
 			ignoreWhitespace:    false,
-			expected:            []string{"git", "-C", "/path/to/worktree", "stash", "show", "-p", "--stat", "--color=always", "--unified=3", "--find-renames=33%", "stash@{5}"},
+			expected:            []string{"git", "-C", "/path/to/worktree", "stash", "show", "-p", "--stat", "-u", "--color=always", "--unified=3", "--find-renames=33%", "stash@{5}"},
 		},
 		{
 			testName:            "Default case",
@@ -137,7 +137,7 @@ func TestStashStashEntryCmdObj(t *testing.T) {
 			contextSize:         3,
 			similarityThreshold: 50,
 			ignoreWhitespace:    true,
-			expected:            []string{"git", "-C", "/path/to/worktree", "stash", "show", "-p", "--stat", "--color=always", "--unified=3", "--ignore-all-space", "--find-renames=50%", "stash@{5}"},
+			expected:            []string{"git", "-C", "/path/to/worktree", "stash", "show", "-p", "--stat", "-u", "--color=always", "--unified=3", "--ignore-all-space", "--find-renames=50%", "stash@{5}"},
 		},
 	}