diff options
author | Jesse Duffield <jessedduffield@gmail.com> | 2022-05-15 20:33:25 +1000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-05-15 20:33:25 +1000 |
commit | f31dcd3091b2b23562bb10afd7c27b6400e9d39a (patch) | |
tree | c6dabe2a861c9ecf79a502aedfc8c8f0eafbda23 /pkg/gui/controllers | |
parent | 8e7f6822fca0ecef541280f31b9507a2ec5e50f6 (diff) | |
parent | 241d182da7d589e4a30520ff8d9ea4143c9e658a (diff) |
Merge pull request #1930 from mark2185/feature/discard-staged-only
Diffstat (limited to 'pkg/gui/controllers')
-rw-r--r-- | pkg/gui/controllers/workspace_reset_controller.go | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/pkg/gui/controllers/workspace_reset_controller.go b/pkg/gui/controllers/workspace_reset_controller.go index dc830b3ba..f34739af7 100644 --- a/pkg/gui/controllers/workspace_reset_controller.go +++ b/pkg/gui/controllers/workspace_reset_controller.go @@ -12,7 +12,7 @@ import ( func (self *FilesController) createResetMenu() error { red := style.FgRed - nukeStr := "reset --hard HEAD && git clean -fd" + nukeStr := "git reset --hard HEAD && git clean -fd" if len(self.model.Submodules) > 0 { nukeStr = fmt.Sprintf("%s (%s)", nukeStr, self.c.Tr.LcAndResetSubmodules) } @@ -66,6 +66,28 @@ func (self *FilesController) createResetMenu() error { }, { LabelColumns: []string{ + self.c.Tr.LcDiscardStagedChanges, + red.Sprint("stash staged and drop stash"), + }, + Tooltip: self.c.Tr.DiscardStagedChangesDescription, + OnPress: func() error { + self.c.LogAction(self.c.Tr.Actions.RemoveStagedFiles) + if !self.helpers.WorkingTree.IsWorkingTreeDirty() { + return self.c.ErrorMsg(self.c.Tr.NoTrackedStagedFilesStash) + } + if err := self.git.Stash.SaveStagedChanges("[lazygit] tmp stash"); err != nil { + return self.c.Error(err) + } + if err := self.git.Stash.DropNewest(); err != nil { + return self.c.Error(err) + } + + return self.c.Refresh(types.RefreshOptions{Mode: types.ASYNC, Scope: []types.RefreshableView{types.FILES}}) + }, + Key: 'S', + }, + { + LabelColumns: []string{ self.c.Tr.LcSoftReset, red.Sprint("git reset --soft HEAD"), }, |