From 2b65bee67572927b3a70df97d423f17c12427c86 Mon Sep 17 00:00:00 2001 From: Stefan Haller Date: Sat, 21 Feb 2026 15:33:48 +0100 Subject: [PATCH] Remove redundant CantPatchWhileRebasingError checks in handlers We don't add the commands to the menu when we're rebasing, so it's pointless to check this in the handlers. I guess alternatively we could add all commands always, and strike out the ones that are not applicable using DisabledReasons. But we don't usually do this in menus (except the global keybindings menu). --- .../custom_patch_options_menu_action.go | 27 ------------------- 1 file changed, 27 deletions(-) diff --git a/pkg/gui/controllers/custom_patch_options_menu_action.go b/pkg/gui/controllers/custom_patch_options_menu_action.go index 793048429..fa39cf374 100644 --- a/pkg/gui/controllers/custom_patch_options_menu_action.go +++ b/pkg/gui/controllers/custom_patch_options_menu_action.go @@ -123,13 +123,6 @@ func (self *CustomPatchOptionsMenuAction) getPatchCommitIndex() int { return -1 } -func (self *CustomPatchOptionsMenuAction) validateNormalWorkingTreeState() (bool, error) { - if self.c.Git().Status.WorkingTreeState().Any() { - return false, errors.New(self.c.Tr.CantPatchWhileRebasingError) - } - return true, nil -} - func (self *CustomPatchOptionsMenuAction) returnFocusFromPatchExplorerIfNecessary() { if self.c.Context().Current().GetKey() == self.c.Contexts().CustomPatchBuilder.GetKey() { self.c.Helpers().PatchBuilding.Escape() @@ -137,10 +130,6 @@ func (self *CustomPatchOptionsMenuAction) returnFocusFromPatchExplorerIfNecessar } func (self *CustomPatchOptionsMenuAction) handleDeletePatchFromCommit() error { - if ok, err := self.validateNormalWorkingTreeState(); !ok { - return err - } - self.returnFocusFromPatchExplorerIfNecessary() return self.c.WithWaitingStatus(self.c.Tr.RebasingStatus, func(gocui.Task) error { @@ -152,10 +141,6 @@ func (self *CustomPatchOptionsMenuAction) handleDeletePatchFromCommit() error { } func (self *CustomPatchOptionsMenuAction) handleMovePatchToSelectedCommit() error { - if ok, err := self.validateNormalWorkingTreeState(); !ok { - return err - } - self.returnFocusFromPatchExplorerIfNecessary() return self.c.WithWaitingStatus(self.c.Tr.RebasingStatus, func(gocui.Task) error { @@ -167,10 +152,6 @@ func (self *CustomPatchOptionsMenuAction) handleMovePatchToSelectedCommit() erro } func (self *CustomPatchOptionsMenuAction) handleMovePatchIntoWorkingTree() error { - if ok, err := self.validateNormalWorkingTreeState(); !ok { - return err - } - self.returnFocusFromPatchExplorerIfNecessary() mustStash := self.c.Helpers().WorkingTree.IsWorkingTreeDirtyExceptSubmodules() @@ -189,10 +170,6 @@ func (self *CustomPatchOptionsMenuAction) handleMovePatchIntoWorkingTree() error } func (self *CustomPatchOptionsMenuAction) handlePullPatchIntoNewCommit() error { - if ok, err := self.validateNormalWorkingTreeState(); !ok { - return err - } - self.returnFocusFromPatchExplorerIfNecessary() commitIndex := self.getPatchCommitIndex() @@ -224,10 +201,6 @@ func (self *CustomPatchOptionsMenuAction) handlePullPatchIntoNewCommit() error { } func (self *CustomPatchOptionsMenuAction) handlePullPatchIntoNewCommitBefore() error { - if ok, err := self.validateNormalWorkingTreeState(); !ok { - return err - } - self.returnFocusFromPatchExplorerIfNecessary() commitIndex := self.getPatchCommitIndex()