mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-11-25 22:32:13 +02:00
Avoid auto-stashing when only submodules are out of date
Stashing doesn't affect submodules, so if you have a working copy that has
out-of-date submodules but no other changes, and then you revert or paste a
commit (or invoke one of the many other lazygit commands that auto-stash, e.g.
undo), lazygit would previously try to stash changes (which did nothing, but
also didn't return an error), perform the operation, and then pop the stash
again. If no stashes existed before, then this would only cause a confusing
error popup ("error: refs/stash@{0} is not a valid reference"), but if there
were stashes, this would try to pop the newest one of these, which is very
undesirable and confusing.
This commit is contained in:
@@ -47,6 +47,14 @@ func AnyStagedFiles(files []*models.File) bool {
|
||||
return lo.SomeBy(files, func(f *models.File) bool { return f.HasStagedChanges })
|
||||
}
|
||||
|
||||
func (self *WorkingTreeHelper) AnyStagedFilesExceptSubmodules() bool {
|
||||
return AnyStagedFilesExceptSubmodules(self.c.Model().Files, self.c.Model().Submodules)
|
||||
}
|
||||
|
||||
func AnyStagedFilesExceptSubmodules(files []*models.File, submoduleConfigs []*models.SubmoduleConfig) bool {
|
||||
return lo.SomeBy(files, func(f *models.File) bool { return f.HasStagedChanges && !f.IsSubmodule(submoduleConfigs) })
|
||||
}
|
||||
|
||||
func (self *WorkingTreeHelper) AnyTrackedFiles() bool {
|
||||
return AnyTrackedFiles(self.c.Model().Files)
|
||||
}
|
||||
@@ -55,12 +63,20 @@ func AnyTrackedFiles(files []*models.File) bool {
|
||||
return lo.SomeBy(files, func(f *models.File) bool { return f.Tracked })
|
||||
}
|
||||
|
||||
func (self *WorkingTreeHelper) IsWorkingTreeDirty() bool {
|
||||
return IsWorkingTreeDirty(self.c.Model().Files)
|
||||
func (self *WorkingTreeHelper) AnyTrackedFilesExceptSubmodules() bool {
|
||||
return AnyTrackedFilesExceptSubmodules(self.c.Model().Files, self.c.Model().Submodules)
|
||||
}
|
||||
|
||||
func IsWorkingTreeDirty(files []*models.File) bool {
|
||||
return AnyStagedFiles(files) || AnyTrackedFiles(files)
|
||||
func AnyTrackedFilesExceptSubmodules(files []*models.File, submoduleConfigs []*models.SubmoduleConfig) bool {
|
||||
return lo.SomeBy(files, func(f *models.File) bool { return f.Tracked && !f.IsSubmodule(submoduleConfigs) })
|
||||
}
|
||||
|
||||
func (self *WorkingTreeHelper) IsWorkingTreeDirtyExceptSubmodules() bool {
|
||||
return IsWorkingTreeDirtyExceptSubmodules(self.c.Model().Files, self.c.Model().Submodules)
|
||||
}
|
||||
|
||||
func IsWorkingTreeDirtyExceptSubmodules(files []*models.File, submoduleConfigs []*models.SubmoduleConfig) bool {
|
||||
return AnyStagedFilesExceptSubmodules(files, submoduleConfigs) || AnyTrackedFilesExceptSubmodules(files, submoduleConfigs)
|
||||
}
|
||||
|
||||
func (self *WorkingTreeHelper) FileForSubmodule(submodule *models.SubmoduleConfig) *models.File {
|
||||
|
||||
Reference in New Issue
Block a user