Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lazygit does not show diff of untracked stashed files #3931

Open
Golim opened this issue Sep 21, 2024 · 4 comments · May be fixed by #3932
Open

Lazygit does not show diff of untracked stashed files #3931

Golim opened this issue Sep 21, 2024 · 4 comments · May be fixed by #3932
Labels
bug Something isn't working

Comments

@Golim
Copy link

Golim commented Sep 21, 2024

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
As it is now: the untracked stashed file is not shown in lazygit.

correct
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

@Golim Golim added the bug Something isn't working label Sep 21, 2024
@Golim Golim linked a pull request Sep 21, 2024 that will close this issue
7 tasks
@stefanhaller
Copy link
Collaborator

I never used the --include-untracked option of git stash, so I have little experience with it. Reading up on it and experimenting with it, I see that if a stash includes untracked files, they are always restored when you pop or apply the stash; there doesn't seem to be an option not to. From this, it follows for me that git show should always show the untracked files; I see no reason why you wouldn't want that, so I'm unsure why the --include-untracked of git show even exists. Not sure what I'm missing here.

That said, since it is an option in git, maybe not everybody wants it, so it should be configurable. But then, lazygit usually follows the philosophy that if there's a way to configure something in git, we don't make it configureable in lazygit because that would be redundant. And in this case, there is a way to configure it in git, by doing git config --global stash.showIncludeUntracked true. This also takes effect in lazygit, so it solves your issue, and I'd be inclined to close your PR.

Let me know if you disagree. I guess you could argue that the default in git is a bad one, and we can make lazygit have a better default. However, you could say the same thing about the rebase.updateRefs config, I think it should also be on by default in git, but it isn't, and we don't turn it on in lazygit. We rely on users setting it in git if they want it. (But then again, we do turn on --rebase-merges by default, even though it's off by default in git, and there is a git config to turn it on, so we are being inconsistent here. Hm.)

Tagging @jesseduffield in case he has any thoughts on all this.

@Golim
Copy link
Author

Golim commented Sep 21, 2024

That's a fair point. However, --include-untracked has no side effects on git stash show (at least that I know of) and to me there are no real reasons why git (or lazygit) should not show untracked stashed files here. That's also the reason why I have not made it configurable here, but I'm obviously not against making it so.

So yes, I'm basically saying that lazygit should have a better default here, considering that it does not have any other effect on the command yet makes our life easier.

@azizj1
Copy link

azizj1 commented Oct 7, 2024

git config --global stash.showIncludeUntracked true

Despite doing this, I'm not 100% getting the desired result. I'm seeing the newly added files here
image

But i'm not seeing it here
image

@jesseduffield
Copy link
Owner

I too wonder why this flag is not passed by git by default. I've asked the following in the git discord (which I'm glad exists because I am not in the mood to learn how the git mailing list works 😉):

Hi all. I'm the maintainer of Lazygit, a TUI for git, and I'd like to understand a bit about the --include-untracked flag in git stash show. I can't imagine why anybody would not want to pass this flag: is this flag not passed by default due to performance or backwards compatibility concerns? I'm considering having Lazygit pass it unconditionally rather than require users to run git config --global stash.showIncludeUntracked true. Thanks

I'm leaning towards just honouring the git config. Pretty hard to go wrong with that approach, even though I think git has no good reason to not include untracked files by default.

At any rate, like @azizj1 shows above, if you do enable that global config value to include untracked, we currently show the untracked files in the main panel, but not in the 'diff files' panel (not a great name I for a panel I admit). So that is a bug.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants