-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
When hiding untracked files, adding a folder adds also untracked files (git add instead of git add -u) #4245
Comments
Yeah, I think this is a problem. I will try to put a PR soon. |
Sorry for being so late. I have been very busy for the last couple of weeks.
Also, during unstaging in filter view, what should be the expected behavior? In my opinion, when in filtered view, we should only consider files in current view for all things (staging, unstaging, commit). But this will complicate a lot of things and might be confusing in many use cases. |
Interesting questions. I don't use the filter feature much, but when playing with it just now, I found it confusing that untracked but staged files don't show up when I filter for only tracked files. In my intuition, a staged file already counts as a tracked file (even though I know that it technically isn't). So I would propose to simply include them (and, for symmetry, probably exclude them when filtering for only untracked files? Not so sure about that). This would solve the problems you brought up, or am I still missing scenarios where it doesn't? Here's a patch that does this: diff --git i/pkg/gui/filetree/file_tree.go w/pkg/gui/filetree/file_tree.go
index 9ef980faa..5298f79e8 100644
--- i/pkg/gui/filetree/file_tree.go
+++ w/pkg/gui/filetree/file_tree.go
@@ -88,9 +88,9 @@ func (self *FileTree) getFilesForDisplay() []*models.File {
case DisplayUnstaged:
return self.FilterFiles(func(file *models.File) bool { return file.HasUnstagedChanges })
case DisplayTracked:
- return self.FilterFiles(func(file *models.File) bool { return file.Tracked })
+ return self.FilterFiles(func(file *models.File) bool { return file.Tracked || file.HasStagedChanges })
case DisplayUntracked:
- return self.FilterFiles(func(file *models.File) bool { return !file.Tracked })
+ return self.FilterFiles(func(file *models.File) bool { return !(file.Tracked || file.HasStagedChanges) })
case DisplayConflicted:
return self.FilterFiles(func(file *models.File) bool { return file.HasMergeConflicts })
default: |
That is a good point. |
Well yes of course. The patch above wasn't meant as the only measure we take, we still also want to do |
This is a nice solution. However, if we unstage in tracked filter view, the untracked files will disappear. This might be a bit confusing, but nevertheless, seems like a good tradeoff to make. |
I don't find this confusing at all. This is not really very different from filtering by staged files, and then unstaging a file (or vice versa); of course the file then disappears. |
Describe the bug
When hiding untracked files, adding a folder adds also untracked files (git add instead of git add -u).
This means you are also in the commit only shown a subset of the files that will be actually commited.
To Reproduce
In a repo, create a folder, add two files, track one file.
Then change the tracked file.
Open lazy git. Filter to tracked files (ctrl+b, t).
Now with space select the folder to commit.
Without your knowledge it also adds the untracked file.
Expected behavior
It should only add from the tracked files, if the view is filtered.
Version info:
commit=, build date=, build source=nix, version=0.45.2, os=linux, arch=amd64, git version=2.47.1
Additional context
There might be a reason to do it this way. If that is the case, at least a warning should be displayed.
The text was updated successfully, but these errors were encountered: