mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-10-20 19:12:29 +03: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:
@@ -100,7 +100,7 @@ func (self *FilesController) createResetMenu() error {
|
||||
Tooltip: self.c.Tr.DiscardStagedChangesDescription,
|
||||
OnPress: func() error {
|
||||
self.c.LogAction(self.c.Tr.Actions.RemoveStagedFiles)
|
||||
if !self.c.Helpers().WorkingTree.IsWorkingTreeDirty() {
|
||||
if !self.c.Helpers().WorkingTree.IsWorkingTreeDirtyExceptSubmodules() {
|
||||
return errors.New(self.c.Tr.NoTrackedStagedFilesStash)
|
||||
}
|
||||
if err := self.c.Git().Stash.SaveStagedChanges("[lazygit] tmp stash"); err != nil {
|
||||
@@ -159,7 +159,7 @@ func (self *FilesController) createResetMenu() error {
|
||||
red.Sprint("git reset --hard HEAD"),
|
||||
},
|
||||
OnPress: func() error {
|
||||
return self.c.ConfirmIf(helpers.IsWorkingTreeDirty(self.c.Model().Files),
|
||||
return self.c.ConfirmIf(helpers.IsWorkingTreeDirtyExceptSubmodules(self.c.Model().Files, self.c.Model().Submodules),
|
||||
types.ConfirmOpts{
|
||||
Title: self.c.Tr.Actions.HardReset,
|
||||
Prompt: self.c.Tr.ResetHardConfirmation,
|
||||
|
Reference in New Issue
Block a user