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 · 2 comments · May be fixed by #3932
Open

Lazygit does not show diff of untracked stashed files #3931

Golim opened this issue Sep 21, 2024 · 2 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.

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.

2 participants