From b2562153970de8f8155740b6b8038de07a97a7d9 Mon Sep 17 00:00:00 2001 From: Stefan Haller Date: Sat, 21 Feb 2026 14:19:28 +0100 Subject: [PATCH 1/7] Say "discard" instead of "remove" when discard changes from a commit "Remove" can be confusing when a deleted file is selected; in this cases it actually "un-removes" it. "Discard" hopefully makes it clearer that we are talking about the change to a file, and not the file itself. --- pkg/gui/controllers/commits_files_controller.go | 2 +- pkg/i18n/english.go | 2 +- pkg/integration/tests/commit/discard_old_file_changes.go | 6 +++--- pkg/integration/tests/commit/discard_submodule_changes.go | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/pkg/gui/controllers/commits_files_controller.go b/pkg/gui/controllers/commits_files_controller.go index e015f9887..61b386f34 100644 --- a/pkg/gui/controllers/commits_files_controller.go +++ b/pkg/gui/controllers/commits_files_controller.go @@ -63,7 +63,7 @@ func (self *CommitFilesController) GetKeybindings(opts types.KeybindingsOpts) [] Key: opts.GetKey(opts.Config.Universal.Remove), Handler: self.withItems(self.discard), GetDisabledReason: self.require(self.itemsSelected()), - Description: self.c.Tr.Remove, + Description: self.c.Tr.Discard, Tooltip: self.c.Tr.DiscardOldFileChangeTooltip, DisplayOnScreen: true, }, diff --git a/pkg/i18n/english.go b/pkg/i18n/english.go index 5d1b80573..390c859c6 100644 --- a/pkg/i18n/english.go +++ b/pkg/i18n/english.go @@ -1545,7 +1545,7 @@ func EnglishTranslationSet() *TranslationSet { Remove: "Remove", DiscardOldFileChangeTooltip: "Discard this commit's changes to this file. This runs an interactive rebase in the background, so you may get a merge conflict if a later commit also changes this file.", DiscardFileChangesTitle: "Discard file changes", - DiscardFileChangesPrompt: "Are you sure you want to remove changes to the selected file(s) from this commit?\n\nThis action will start a rebase, reverting these file changes. Be aware that if subsequent commits depend on these changes, you may need to resolve conflicts.\nNote: This will also reset any active custom patches.", + DiscardFileChangesPrompt: "Are you sure you want to discard changes to the selected file(s) from this commit?\n\nThis action will start a rebase, reverting these file changes. Be aware that if subsequent commits depend on these changes, you may need to resolve conflicts.\nNote: This will also reset any active custom patches.", DisabledForGPG: "Feature not available for users using GPG.\n\nIf you are using a passphrase agent (e.g. gpg-agent) so that you don't have to type your passphrase when signing, you can enable this feature by adding\n\ngit:\n overrideGpg: true\n\nto your lazygit config file.", CreateRepo: "Not in a git repository. Create a new git repository? (y/N): ", BareRepo: "You've attempted to open Lazygit in a bare repo but Lazygit does not yet support bare repos. Open most recent repo? (y/n) ", diff --git a/pkg/integration/tests/commit/discard_old_file_changes.go b/pkg/integration/tests/commit/discard_old_file_changes.go index 3e4057af5..cf70e5c2b 100644 --- a/pkg/integration/tests/commit/discard_old_file_changes.go +++ b/pkg/integration/tests/commit/discard_old_file_changes.go @@ -57,7 +57,7 @@ var DiscardOldFileChanges = NewIntegrationTest(NewIntegrationTestArgs{ t.ExpectPopup().Confirmation(). Title(Equals("Discard file changes")). - Content(Equals("Are you sure you want to remove changes to the selected file(s) from this commit?\n\nThis action will start a rebase, reverting these file changes. Be aware that if subsequent commits depend on these changes, you may need to resolve conflicts.\nNote: This will also reset any active custom patches.")). + Content(Equals("Are you sure you want to discard changes to the selected file(s) from this commit?\n\nThis action will start a rebase, reverting these file changes. Be aware that if subsequent commits depend on these changes, you may need to resolve conflicts.\nNote: This will also reset any active custom patches.")). Confirm() t.Views().CommitFiles(). @@ -99,7 +99,7 @@ var DiscardOldFileChanges = NewIntegrationTest(NewIntegrationTestArgs{ t.ExpectPopup().Confirmation(). Title(Equals("Discard file changes")). - Content(Equals("Are you sure you want to remove changes to the selected file(s) from this commit?\n\nThis action will start a rebase, reverting these file changes. Be aware that if subsequent commits depend on these changes, you may need to resolve conflicts.\nNote: This will also reset any active custom patches.")). + Content(Equals("Are you sure you want to discard changes to the selected file(s) from this commit?\n\nThis action will start a rebase, reverting these file changes. Be aware that if subsequent commits depend on these changes, you may need to resolve conflicts.\nNote: This will also reset any active custom patches.")). Confirm() t.Views().CommitFiles(). @@ -157,7 +157,7 @@ var DiscardOldFileChanges = NewIntegrationTest(NewIntegrationTestArgs{ t.ExpectPopup().Confirmation(). Title(Equals("Discard file changes")). - Content(Equals("Are you sure you want to remove changes to the selected file(s) from this commit?\n\nThis action will start a rebase, reverting these file changes. Be aware that if subsequent commits depend on these changes, you may need to resolve conflicts.\nNote: This will also reset any active custom patches.")). + Content(Equals("Are you sure you want to discard changes to the selected file(s) from this commit?\n\nThis action will start a rebase, reverting these file changes. Be aware that if subsequent commits depend on these changes, you may need to resolve conflicts.\nNote: This will also reset any active custom patches.")). Confirm() // "Building patch" will still be in this view if the patch isn't reset properly diff --git a/pkg/integration/tests/commit/discard_submodule_changes.go b/pkg/integration/tests/commit/discard_submodule_changes.go index b457a3a41..5beb57736 100644 --- a/pkg/integration/tests/commit/discard_submodule_changes.go +++ b/pkg/integration/tests/commit/discard_submodule_changes.go @@ -45,7 +45,7 @@ var DiscardSubmoduleChanges = NewIntegrationTest(NewIntegrationTestArgs{ t.ExpectPopup().Confirmation(). Title(Equals("Discard file changes")). - Content(Contains("Are you sure you want to remove changes to the selected file(s) from this commit?")). + Content(Contains("Are you sure you want to discard changes to the selected file(s) from this commit?")). Confirm() t.Shell().RunCommand([]string{"git", "submodule", "update"}) From 7f9bfaec08a226ab910594b015e1c715402d49d7 Mon Sep 17 00:00:00 2001 From: Stefan Haller Date: Sat, 21 Feb 2026 14:31:14 +0100 Subject: [PATCH 2/7] Warn more prominently about resetting the patch when discarding changes Only mention resetting the patch when there actually is one. This way users have to read less text in the normal case, and the added note hopefully stands out more if there is one. Also, separate the note from the previous text by a blank line. --- pkg/gui/controllers/commits_files_controller.go | 6 +++++- pkg/i18n/english.go | 4 +++- pkg/integration/tests/commit/discard_old_file_changes.go | 6 +++--- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/pkg/gui/controllers/commits_files_controller.go b/pkg/gui/controllers/commits_files_controller.go index 61b386f34..58472d871 100644 --- a/pkg/gui/controllers/commits_files_controller.go +++ b/pkg/gui/controllers/commits_files_controller.go @@ -310,9 +310,13 @@ func (self *CommitFilesController) discard(selectedNodes []*filetree.CommitFileN return err } + prompt := lo.Ternary(self.c.Git().Patch.PatchBuilder.Active(), + self.c.Tr.DiscardFileChangesPromptResetPatch, + self.c.Tr.DiscardFileChangesPrompt) + self.c.Confirm(types.ConfirmOpts{ Title: self.c.Tr.DiscardFileChangesTitle, - Prompt: self.c.Tr.DiscardFileChangesPrompt, + Prompt: prompt, HandleConfirm: func() error { return self.c.WithWaitingStatus(self.c.Tr.RebasingStatus, func(gocui.Task) error { var filePaths []string diff --git a/pkg/i18n/english.go b/pkg/i18n/english.go index 390c859c6..e8f5b50f7 100644 --- a/pkg/i18n/english.go +++ b/pkg/i18n/english.go @@ -438,6 +438,7 @@ type TranslationSet struct { DiscardOldFileChangeTooltip string DiscardFileChangesTitle string DiscardFileChangesPrompt string + DiscardFileChangesPromptResetPatch string DisabledForGPG string CreateRepo string BareRepo string @@ -1545,7 +1546,8 @@ func EnglishTranslationSet() *TranslationSet { Remove: "Remove", DiscardOldFileChangeTooltip: "Discard this commit's changes to this file. This runs an interactive rebase in the background, so you may get a merge conflict if a later commit also changes this file.", DiscardFileChangesTitle: "Discard file changes", - DiscardFileChangesPrompt: "Are you sure you want to discard changes to the selected file(s) from this commit?\n\nThis action will start a rebase, reverting these file changes. Be aware that if subsequent commits depend on these changes, you may need to resolve conflicts.\nNote: This will also reset any active custom patches.", + DiscardFileChangesPrompt: "Are you sure you want to discard changes to the selected file(s) from this commit?\n\nThis action will start a rebase, reverting these file changes. Be aware that if subsequent commits depend on these changes, you may need to resolve conflicts.", + DiscardFileChangesPromptResetPatch: "Are you sure you want to discard changes to the selected file(s) from this commit?\n\nThis action will start a rebase, reverting these file changes. Be aware that if subsequent commits depend on these changes, you may need to resolve conflicts.\n\nNote: This will reset the active custom patch!", DisabledForGPG: "Feature not available for users using GPG.\n\nIf you are using a passphrase agent (e.g. gpg-agent) so that you don't have to type your passphrase when signing, you can enable this feature by adding\n\ngit:\n overrideGpg: true\n\nto your lazygit config file.", CreateRepo: "Not in a git repository. Create a new git repository? (y/N): ", BareRepo: "You've attempted to open Lazygit in a bare repo but Lazygit does not yet support bare repos. Open most recent repo? (y/n) ", diff --git a/pkg/integration/tests/commit/discard_old_file_changes.go b/pkg/integration/tests/commit/discard_old_file_changes.go index cf70e5c2b..0268396db 100644 --- a/pkg/integration/tests/commit/discard_old_file_changes.go +++ b/pkg/integration/tests/commit/discard_old_file_changes.go @@ -57,7 +57,7 @@ var DiscardOldFileChanges = NewIntegrationTest(NewIntegrationTestArgs{ t.ExpectPopup().Confirmation(). Title(Equals("Discard file changes")). - Content(Equals("Are you sure you want to discard changes to the selected file(s) from this commit?\n\nThis action will start a rebase, reverting these file changes. Be aware that if subsequent commits depend on these changes, you may need to resolve conflicts.\nNote: This will also reset any active custom patches.")). + Content(Equals("Are you sure you want to discard changes to the selected file(s) from this commit?\n\nThis action will start a rebase, reverting these file changes. Be aware that if subsequent commits depend on these changes, you may need to resolve conflicts.")). Confirm() t.Views().CommitFiles(). @@ -99,7 +99,7 @@ var DiscardOldFileChanges = NewIntegrationTest(NewIntegrationTestArgs{ t.ExpectPopup().Confirmation(). Title(Equals("Discard file changes")). - Content(Equals("Are you sure you want to discard changes to the selected file(s) from this commit?\n\nThis action will start a rebase, reverting these file changes. Be aware that if subsequent commits depend on these changes, you may need to resolve conflicts.\nNote: This will also reset any active custom patches.")). + Content(Equals("Are you sure you want to discard changes to the selected file(s) from this commit?\n\nThis action will start a rebase, reverting these file changes. Be aware that if subsequent commits depend on these changes, you may need to resolve conflicts.")). Confirm() t.Views().CommitFiles(). @@ -157,7 +157,7 @@ var DiscardOldFileChanges = NewIntegrationTest(NewIntegrationTestArgs{ t.ExpectPopup().Confirmation(). Title(Equals("Discard file changes")). - Content(Equals("Are you sure you want to discard changes to the selected file(s) from this commit?\n\nThis action will start a rebase, reverting these file changes. Be aware that if subsequent commits depend on these changes, you may need to resolve conflicts.\nNote: This will also reset any active custom patches.")). + Content(Equals("Are you sure you want to discard changes to the selected file(s) from this commit?\n\nThis action will start a rebase, reverting these file changes. Be aware that if subsequent commits depend on these changes, you may need to resolve conflicts.\n\nNote: This will reset the active custom patch!")). Confirm() // "Building patch" will still be in this view if the patch isn't reset properly From 2b65bee67572927b3a70df97d423f17c12427c86 Mon Sep 17 00:00:00 2001 From: Stefan Haller Date: Sat, 21 Feb 2026 15:33:48 +0100 Subject: [PATCH 3/7] 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() From 35d06c32d7aac9d8067f9acce37fe775e890656c Mon Sep 17 00:00:00 2001 From: Stefan Haller Date: Sat, 21 Feb 2026 15:49:07 +0100 Subject: [PATCH 4/7] Turn error checks in discard handler into DisabledReasons That's how we usually do this; it's useful to see in the keybindings menu that the command is disabled. --- .../controllers/commits_files_controller.go | 30 ++++++++++++------- .../helpers/patch_building_helper.go | 8 ----- 2 files changed, 20 insertions(+), 18 deletions(-) diff --git a/pkg/gui/controllers/commits_files_controller.go b/pkg/gui/controllers/commits_files_controller.go index 58472d871..e8dbca90d 100644 --- a/pkg/gui/controllers/commits_files_controller.go +++ b/pkg/gui/controllers/commits_files_controller.go @@ -62,7 +62,7 @@ func (self *CommitFilesController) GetKeybindings(opts types.KeybindingsOpts) [] { Key: opts.GetKey(opts.Config.Universal.Remove), Handler: self.withItems(self.discard), - GetDisabledReason: self.require(self.itemsSelected()), + GetDisabledReason: self.require(self.itemsSelected(self.canDiscardFileChanges)), Description: self.c.Tr.Discard, Tooltip: self.c.Tr.DiscardOldFileChangeTooltip, DisplayOnScreen: true, @@ -301,15 +301,6 @@ func (self *CommitFilesController) checkout(node *filetree.CommitFileNode) error } func (self *CommitFilesController) discard(selectedNodes []*filetree.CommitFileNode) error { - parentContext := self.c.Context().Current().GetParentContext() - if parentContext == nil || parentContext.GetKey() != context.LOCAL_COMMITS_CONTEXT_KEY { - return errors.New(self.c.Tr.CanOnlyDiscardFromLocalCommits) - } - - if ok, err := self.c.Helpers().PatchBuilding.ValidateNormalWorkingTreeState(); !ok { - return err - } - prompt := lo.Ternary(self.c.Git().Patch.PatchBuilder.Active(), self.c.Tr.DiscardFileChangesPromptResetPatch, self.c.Tr.DiscardFileChangesPrompt) @@ -351,6 +342,25 @@ func (self *CommitFilesController) discard(selectedNodes []*filetree.CommitFileN return nil } +func (self *CommitFilesController) canDiscardFileChanges(nodes []*filetree.CommitFileNode) *types.DisabledReason { + parentContext := self.c.Context().Current().GetParentContext() + if parentContext == nil || parentContext.GetKey() != context.LOCAL_COMMITS_CONTEXT_KEY { + return &types.DisabledReason{ + Text: self.c.Tr.CanOnlyDiscardFromLocalCommits, + ShowErrorInPanel: true, + } + } + + if self.c.Git().Status.WorkingTreeState().Any() { + return &types.DisabledReason{ + Text: self.c.Tr.CantPatchWhileRebasingError, + ShowErrorInPanel: true, + } + } + + return nil +} + func (self *CommitFilesController) open(node *filetree.CommitFileNode) error { return self.c.Helpers().Files.OpenFile(node.GetPath()) } diff --git a/pkg/gui/controllers/helpers/patch_building_helper.go b/pkg/gui/controllers/helpers/patch_building_helper.go index 72ece0a71..fd5136b8a 100644 --- a/pkg/gui/controllers/helpers/patch_building_helper.go +++ b/pkg/gui/controllers/helpers/patch_building_helper.go @@ -1,7 +1,6 @@ package helpers import ( - "errors" "fmt" "github.com/jesseduffield/lazygit/pkg/commands/patch" @@ -22,13 +21,6 @@ func NewPatchBuildingHelper( } } -func (self *PatchBuildingHelper) ValidateNormalWorkingTreeState() (bool, error) { - if self.c.Git().Status.WorkingTreeState().Any() { - return false, errors.New(self.c.Tr.CantPatchWhileRebasingError) - } - return true, nil -} - func (self *PatchBuildingHelper) ShowHunkStagingHint() { if !self.c.AppState.DidShowHunkStagingHint && self.c.UserConfig().Gui.UseHunkModeInStagingView { self.c.AppState.DidShowHunkStagingHint = true From b3d81a0c7c668fedd3419dfda74474576a5d1f8f Mon Sep 17 00:00:00 2001 From: Stefan Haller Date: Sat, 21 Feb 2026 15:55:47 +0100 Subject: [PATCH 5/7] Add DisabledReason for discarding from a multiselection of commits --- pkg/gui/controllers/commits_files_controller.go | 7 +++++++ pkg/i18n/english.go | 2 ++ 2 files changed, 9 insertions(+) diff --git a/pkg/gui/controllers/commits_files_controller.go b/pkg/gui/controllers/commits_files_controller.go index e8dbca90d..1412254e7 100644 --- a/pkg/gui/controllers/commits_files_controller.go +++ b/pkg/gui/controllers/commits_files_controller.go @@ -351,6 +351,13 @@ func (self *CommitFilesController) canDiscardFileChanges(nodes []*filetree.Commi } } + if self.c.Contexts().LocalCommits.AreMultipleItemsSelected() { + return &types.DisabledReason{ + Text: self.c.Tr.CannotDiscardFromMultipleCommits, + ShowErrorInPanel: true, + } + } + if self.c.Git().Status.WorkingTreeState().Any() { return &types.DisabledReason{ Text: self.c.Tr.CantPatchWhileRebasingError, diff --git a/pkg/i18n/english.go b/pkg/i18n/english.go index e8f5b50f7..8d66d546a 100644 --- a/pkg/i18n/english.go +++ b/pkg/i18n/english.go @@ -434,6 +434,7 @@ type TranslationSet struct { CheckoutCommitFileTooltip string CannotCheckoutWithModifiedFilesErr string CanOnlyDiscardFromLocalCommits string + CannotDiscardFromMultipleCommits string Remove string DiscardOldFileChangeTooltip string DiscardFileChangesTitle string @@ -1543,6 +1544,7 @@ func EnglishTranslationSet() *TranslationSet { CheckoutCommitFileTooltip: "Checkout file. This replaces the file in your working tree with the version from the selected commit.", CannotCheckoutWithModifiedFilesErr: "You have local modifications for the file(s) you are trying to check out. You need to stash or discard these first.", CanOnlyDiscardFromLocalCommits: "Changes can only be discarded from local commits", + CannotDiscardFromMultipleCommits: "Changes cannot be discarded from a multiselection of commits", Remove: "Remove", DiscardOldFileChangeTooltip: "Discard this commit's changes to this file. This runs an interactive rebase in the background, so you may get a merge conflict if a later commit also changes this file.", DiscardFileChangesTitle: "Discard file changes", From 0f2f20b900bd4bb0610bda9ae89890e3ffe1e27d Mon Sep 17 00:00:00 2001 From: Jesse Duffield Date: Sun, 8 Feb 2026 09:04:26 +1100 Subject: [PATCH 6/7] Allow discarding lines from patch directly I always press 'd' in the patch building view, expecting that I can do exactly what I can do in the staging view, to find out I need to go space -> ctrl+p -> d and I think it's time to honour the muscle memory and support this convenience keybinding. --- docs-master/keybindings/Keybindings_en.md | 3 +- docs-master/keybindings/Keybindings_ja.md | 3 +- docs-master/keybindings/Keybindings_ko.md | 3 +- docs-master/keybindings/Keybindings_nl.md | 3 +- docs-master/keybindings/Keybindings_pl.md | 3 +- docs-master/keybindings/Keybindings_pt.md | 3 +- docs-master/keybindings/Keybindings_ru.md | 3 +- docs-master/keybindings/Keybindings_zh-CN.md | 3 +- docs-master/keybindings/Keybindings_zh-TW.md | 3 +- .../controllers/patch_building_controller.go | 75 +++++++++++++++++++ pkg/i18n/english.go | 12 +++ .../discard_lines_from_commit.go | 63 ++++++++++++++++ pkg/integration/tests/test_list.go | 1 + 13 files changed, 169 insertions(+), 9 deletions(-) create mode 100644 pkg/integration/tests/patch_building/discard_lines_from_commit.go diff --git a/docs-master/keybindings/Keybindings_en.md b/docs-master/keybindings/Keybindings_en.md index b570e2681..9e2bce45b 100644 --- a/docs-master/keybindings/Keybindings_en.md +++ b/docs-master/keybindings/Keybindings_en.md @@ -60,7 +60,7 @@ _Legend: `` means ctrl+b, `` means alt+b, `B` means shift+b_ | `` `` | Copy path to clipboard | | | `` y `` | Copy to clipboard | | | `` c `` | Checkout | Checkout file. This replaces the file in your working tree with the version from the selected commit. | -| `` d `` | Remove | Discard this commit's changes to this file. This runs an interactive rebase in the background, so you may get a merge conflict if a later commit also changes this file. | +| `` d `` | Discard | Discard this commit's changes to this file. This runs an interactive rebase in the background, so you may get a merge conflict if a later commit also changes this file. | | `` o `` | Open file | Open file in default application. | | `` e `` | Edit | Open file in external editor. | | `` `` | Open external diff tool (git difftool) | | @@ -237,6 +237,7 @@ _Legend: `` means ctrl+b, `` means alt+b, `B` means shift+b_ | `` o `` | Open file | Open file in default application. | | `` e `` | Edit file | Open file in external editor. | | `` `` | Toggle lines in patch | | +| `` d `` | Remove lines from commit | Remove the selected lines from this commit. This runs an interactive rebase in the background, so you may get a merge conflict if a later commit also changes these lines. | | `` `` | Exit custom patch builder | | | `` / `` | Search the current view by text | | diff --git a/docs-master/keybindings/Keybindings_ja.md b/docs-master/keybindings/Keybindings_ja.md index b657aa794..ce9657e4e 100644 --- a/docs-master/keybindings/Keybindings_ja.md +++ b/docs-master/keybindings/Keybindings_ja.md @@ -108,7 +108,7 @@ _凡例:`<c-b>` はctrl+b、`<a-b>` はalt+b、`B` はshift+bを意味 | `` `` | パスをクリップボードにコピー | | | `` y `` | クリップボードにコピー | | | `` c `` | チェックアウト(ブランチの切り替え) | ファイルをチェックアウトします。これにより、作業ツリー内のファイルが選択したコミットのバージョンに置き換えられます。 | -| `` d `` | 削除 | このコミットのこのファイルへの変更を破棄します。これはバックグラウンドで対話的なリベースを実行するため、後のコミットでもこのファイルが変更されている場合、マージコンフリクトが発生する可能性があります。 | +| `` d `` | 破棄 | このコミットのこのファイルへの変更を破棄します。これはバックグラウンドで対話的なリベースを実行するため、後のコミットでもこのファイルが変更されている場合、マージコンフリクトが発生する可能性があります。 | | `` o `` | ファイルを開く | デフォルトのアプリケーションでファイルを開きます。 | | `` e `` | 編集 | 外部エディタでファイルを開きます。 | | `` `` | 外部差分ツールを開く(git difftool) | | @@ -278,6 +278,7 @@ _凡例:`<c-b>` はctrl+b、`<a-b>` はalt+b、`B` はshift+bを意味 | `` o `` | ファイルを開く | デフォルトのアプリケーションでファイルを開きます。 | | `` e `` | ファイルを編集 | 外部エディタでファイルを開きます。 | | `` `` | パッチ内の行を切り替え | | +| `` d `` | Remove lines from commit | Remove the selected lines from this commit. This runs an interactive rebase in the background, so you may get a merge conflict if a later commit also changes these lines. | | `` `` | カスタムパッチビルダーを終了 | | | `` / `` | 現在のビューをテキストで検索 | | diff --git a/docs-master/keybindings/Keybindings_ko.md b/docs-master/keybindings/Keybindings_ko.md index 0860c8571..134c0ae04 100644 --- a/docs-master/keybindings/Keybindings_ko.md +++ b/docs-master/keybindings/Keybindings_ko.md @@ -178,6 +178,7 @@ _Legend: `` means ctrl+b, `` means alt+b, `B` means shift+b_ | `` o `` | 파일 닫기 | Open file in default application. | | `` e `` | 파일 편집 | Open file in external editor. | | `` `` | Line(s)을 패치에 추가/삭제 | | +| `` d `` | Remove lines from commit | Remove the selected lines from this commit. This runs an interactive rebase in the background, so you may get a merge conflict if a later commit also changes these lines. | | `` `` | Exit custom patch builder | | | `` / `` | 검색 시작 | | @@ -337,7 +338,7 @@ _Legend: `` means ctrl+b, `` means alt+b, `B` means shift+b_ | `` `` | 파일명을 클립보드에 복사 | | | `` y `` | 클립보드에 복사 | | | `` c `` | 체크아웃 | Checkout file | -| `` d `` | Remove | Discard this commit's changes to this file | +| `` d `` | View 'discard changes' options | Discard this commit's changes to this file | | `` o `` | 파일 닫기 | Open file in default application. | | `` e `` | Edit | Open file in external editor. | | `` `` | Open external diff tool (git difftool) | | diff --git a/docs-master/keybindings/Keybindings_nl.md b/docs-master/keybindings/Keybindings_nl.md index 0bfffcb3d..ec88b025d 100644 --- a/docs-master/keybindings/Keybindings_nl.md +++ b/docs-master/keybindings/Keybindings_nl.md @@ -138,7 +138,7 @@ _Legend: `` means ctrl+b, `` means alt+b, `B` means shift+b_ | `` `` | Kopieer de bestandsnaam naar het klembord | | | `` y `` | Copy to clipboard | | | `` c `` | Uitchecken | Bestand uitchecken | -| `` d `` | Remove | Uitsluit deze commit zijn veranderingen aan dit bestand | +| `` d `` | Bekijk 'veranderingen ongedaan maken' opties | Uitsluit deze commit zijn veranderingen aan dit bestand | | `` o `` | Open bestand | Open file in default application. | | `` e `` | Edit | Open file in external editor. | | `` `` | Open external diff tool (git difftool) | | @@ -245,6 +245,7 @@ _Legend: `` means ctrl+b, `` means alt+b, `B` means shift+b_ | `` o `` | Open bestand | Open file in default application. | | `` e `` | Verander bestand | Open file in external editor. | | `` `` | Voeg toe/verwijder lijn(en) in patch | | +| `` d `` | Remove lines from commit | Remove the selected lines from this commit. This runs an interactive rebase in the background, so you may get a merge conflict if a later commit also changes these lines. | | `` `` | Sluit lijn-bij-lijn modus | | | `` / `` | Start met zoeken | | diff --git a/docs-master/keybindings/Keybindings_pl.md b/docs-master/keybindings/Keybindings_pl.md index 656f16a76..bb0907326 100644 --- a/docs-master/keybindings/Keybindings_pl.md +++ b/docs-master/keybindings/Keybindings_pl.md @@ -124,6 +124,7 @@ _Legenda: `` oznacza ctrl+b, `` oznacza alt+b, `B` oznacza shift+b_ | `` o `` | Otwórz plik | Otwórz plik w domyślnej aplikacji. | | `` e `` | Edytuj plik | Otwórz plik w zewnętrznym edytorze. | | `` `` | Przełącz linie w łatce | | +| `` d `` | Remove lines from commit | Remove the selected lines from this commit. This runs an interactive rebase in the background, so you may get a merge conflict if a later commit also changes these lines. | | `` `` | Wyjdź z budowniczego niestandardowej łatki | | | `` / `` | Szukaj w bieżącym widoku po tekście | | @@ -268,7 +269,7 @@ _Legenda: `` oznacza ctrl+b, `` oznacza alt+b, `B` oznacza shift+b_ | `` `` | Kopiuj ścieżkę do schowka | | | `` y `` | Kopiuj do schowka | | | `` c `` | Przełącz | Przełącz plik. Zastępuje plik w twoim drzewie roboczym wersją z wybranego commita. | -| `` d `` | Usuń | Odrzuć zmiany w tym pliku z tego commita. Uruchamia interaktywny rebase w tle, więc możesz otrzymać konflikt scalania, jeśli późniejszy commit również zmienia ten plik. | +| `` d `` | Odrzuć | Odrzuć zmiany w tym pliku z tego commita. Uruchamia interaktywny rebase w tle, więc możesz otrzymać konflikt scalania, jeśli późniejszy commit również zmienia ten plik. | | `` o `` | Otwórz plik | Otwórz plik w domyślnej aplikacji. | | `` e `` | Edytuj | Otwórz plik w zewnętrznym edytorze. | | `` `` | Otwórz zewnętrzne narzędzie różnic (git difftool) | | diff --git a/docs-master/keybindings/Keybindings_pt.md b/docs-master/keybindings/Keybindings_pt.md index e7b316e72..d55e4ae1a 100644 --- a/docs-master/keybindings/Keybindings_pt.md +++ b/docs-master/keybindings/Keybindings_pt.md @@ -142,7 +142,7 @@ _Legend: `` means ctrl+b, `` means alt+b, `B` means shift+b_ | `` `` | Copy path to clipboard | | | `` y `` | Copy to clipboard | | | `` c `` | Verificar | Arquivo de check-out. Isso substitui o arquivo em sua árvore de trabalho com a versão do commit selecionado. | -| `` d `` | Remover | Descartar as alterações desse commit para este arquivo. Isso executa uma rebase interativa em segundo plano, então você pode ter um conflito de merge se um commit posterior também alterar este arquivo. | +| `` d `` | Descartar | Descartar as alterações desse commit para este arquivo. Isso executa uma rebase interativa em segundo plano, então você pode ter um conflito de merge se um commit posterior também alterar este arquivo. | | `` o `` | Abrir arquivo | Abrir arquivo no aplicativo padrão. | | `` e `` | Editar | Abrir arquivo no editor externo. | | `` `` | Abrir ferramenta de diff externa (git difftool) | | @@ -295,6 +295,7 @@ _Legend: `` means ctrl+b, `` means alt+b, `B` means shift+b_ | `` o `` | Abrir arquivo | Abrir arquivo no aplicativo padrão. | | `` e `` | Editar arquivo | Abrir arquivo no editor externo. | | `` `` | Alternar linhas no caminho | | +| `` d `` | Remove lines from commit | Remove the selected lines from this commit. This runs an interactive rebase in the background, so you may get a merge conflict if a later commit also changes these lines. | | `` `` | Sair do construtor de patch personalizado | | | `` / `` | Search the current view by text | | diff --git a/docs-master/keybindings/Keybindings_ru.md b/docs-master/keybindings/Keybindings_ru.md index df0a4ce1f..085b4e00b 100644 --- a/docs-master/keybindings/Keybindings_ru.md +++ b/docs-master/keybindings/Keybindings_ru.md @@ -138,6 +138,7 @@ _Связки клавиш_ | `` o `` | Открыть файл | Open file in default application. | | `` e `` | Редактировать файл | Open file in external editor. | | `` `` | Добавить/удалить строку(и) для патча | | +| `` d `` | Remove lines from commit | Remove the selected lines from this commit. This runs an interactive rebase in the background, so you may get a merge conflict if a later commit also changes these lines. | | `` `` | Выйти из сборщика пользовательских патчей | | | `` / `` | Найти | | @@ -296,7 +297,7 @@ _Связки клавиш_ | `` `` | Скопировать название файла в буфер обмена | | | `` y `` | Copy to clipboard | | | `` c `` | Переключить | Переключить файл | -| `` d `` | Remove | Отменить изменения коммита в этом файле | +| `` d `` | Просмотреть параметры «отмены изменении» | Отменить изменения коммита в этом файле | | `` o `` | Открыть файл | Open file in default application. | | `` e `` | Edit | Open file in external editor. | | `` `` | Open external diff tool (git difftool) | | diff --git a/docs-master/keybindings/Keybindings_zh-CN.md b/docs-master/keybindings/Keybindings_zh-CN.md index 169dbb9c8..c29102c3e 100644 --- a/docs-master/keybindings/Keybindings_zh-CN.md +++ b/docs-master/keybindings/Keybindings_zh-CN.md @@ -172,7 +172,7 @@ _图例:`` 意味着ctrl+b, `意味着Alt+b, `B` 意味着shift+b_ | `` `` | 复制路径到剪贴板 | | | `` y `` | 复制到剪贴板 | | | `` c `` | 检出 | 检出文件 | -| `` d `` | 删除 | 放弃对此文件的提交变更 | +| `` d `` | 查看'放弃变更'选项 | 放弃对此文件的提交变更 | | `` o `` | 打开文件 | 使用默认程序打开该文件 | | `` e `` | 编辑(Edit) | 使用外部编辑器打开文件 | | `` `` | 使用外部差异比较工具(git difftool) | | @@ -260,6 +260,7 @@ _图例:`` 意味着ctrl+b, `意味着Alt+b, `B` 意味着shift+b_ | `` o `` | 打开文件 | 使用默认程序打开该文件 | | `` e `` | 编辑文件 | 使用外部编辑器打开文件 | | `` `` | 添加/移除 行到补丁 | | +| `` d `` | Remove lines from commit | Remove the selected lines from this commit. This runs an interactive rebase in the background, so you may get a merge conflict if a later commit also changes these lines. | | `` `` | 退出逐行模式 | | | `` / `` | 开始搜索 | | diff --git a/docs-master/keybindings/Keybindings_zh-TW.md b/docs-master/keybindings/Keybindings_zh-TW.md index 107976c26..c70915ad1 100644 --- a/docs-master/keybindings/Keybindings_zh-TW.md +++ b/docs-master/keybindings/Keybindings_zh-TW.md @@ -72,6 +72,7 @@ _說明:`` 表示 Ctrl+B、`` 表示 Alt+B,`B`表示 Shift+B | `` o `` | 開啟檔案 | 使用預設軟體開啟 | | `` e `` | 編輯檔案 | 使用外部編輯器開啟 | | `` `` | 向 (或從) 補丁中添加/刪除行 | | +| `` d `` | Remove lines from commit | Remove the selected lines from this commit. This runs an interactive rebase in the background, so you may get a merge conflict if a later commit also changes these lines. | | `` `` | 退出自訂補丁建立器 | | | `` / `` | 搜尋 | | @@ -230,7 +231,7 @@ _說明:`` 表示 Ctrl+B、`` 表示 Alt+B,`B`表示 Shift+B | `` `` | 複製檔案名稱到剪貼簿 | | | `` y `` | 複製到剪貼簿 | | | `` c `` | 檢出 | 檢出檔案 | -| `` d `` | Remove | Discard this commit's changes to this file. This runs an interactive rebase in the background, so you may get a merge conflict if a later commit also changes this file. | +| `` d `` | 捨棄 | Discard this commit's changes to this file. This runs an interactive rebase in the background, so you may get a merge conflict if a later commit also changes this file. | | `` o `` | 開啟檔案 | 使用預設軟體開啟 | | `` e `` | 編輯 | 使用外部編輯器開啟 | | `` `` | 開啟外部差異工具 (git difftool) | | diff --git a/pkg/gui/controllers/patch_building_controller.go b/pkg/gui/controllers/patch_building_controller.go index c4f8390f6..f20173d53 100644 --- a/pkg/gui/controllers/patch_building_controller.go +++ b/pkg/gui/controllers/patch_building_controller.go @@ -1,7 +1,10 @@ package controllers import ( + "fmt" + "github.com/jesseduffield/gocui" + "github.com/jesseduffield/lazygit/pkg/gui/keybindings" "github.com/jesseduffield/lazygit/pkg/gui/types" "github.com/samber/lo" ) @@ -42,6 +45,14 @@ func (self *PatchBuildingController) GetKeybindings(opts types.KeybindingsOpts) Description: self.c.Tr.ToggleSelectionForPatch, DisplayOnScreen: true, }, + { + Key: opts.GetKey(opts.Config.Universal.Remove), + Handler: self.discardSelection, + GetDisabledReason: self.getDisabledReasonForDiscard, + Description: self.c.Tr.RemoveSelectionFromPatch, + Tooltip: self.c.Tr.RemoveSelectionFromPatchTooltip, + DisplayOnScreen: true, + }, { Key: opts.GetKey(opts.Config.Universal.Return), Handler: self.Escape, @@ -168,6 +179,70 @@ func (self *PatchBuildingController) toggleSelection() error { return nil } +func (self *PatchBuildingController) getDisabledReasonForDiscard() *types.DisabledReason { + if !self.c.Git().Patch.PatchBuilder.CanRebase { + return &types.DisabledReason{Text: self.c.Tr.CanOnlyDiscardFromLocalCommits, ShowErrorInPanel: true} + } + if self.c.Git().Status.WorkingTreeState().Any() { + return &types.DisabledReason{Text: self.c.Tr.CantPatchWhileRebasingError, ShowErrorInPanel: true} + } + if self.c.UserConfig().Git.DiffContextSize == 0 { + text := fmt.Sprintf(self.c.Tr.Actions.NotEnoughContextToRemoveLines, + keybindings.Label(self.c.UserConfig().Keybinding.Universal.IncreaseContextInDiffView)) + return &types.DisabledReason{Text: text, ShowErrorInPanel: true} + } + return nil +} + +func (self *PatchBuildingController) discardSelection() error { + prompt := lo.Ternary(self.c.Git().Patch.PatchBuilder.IsEmpty(), + self.c.Tr.DiscardLinesFromCommitPrompt, + self.c.Tr.DiscardLinesFromCommitPromptWithReset) + + self.c.Confirm(types.ConfirmOpts{ + Title: self.c.Tr.DiscardLinesFromCommitTitle, + Prompt: prompt, + HandleConfirm: func() error { + return self.discardSelectionFromCommit() + }, + }) + + return nil +} + +func (self *PatchBuildingController) discardSelectionFromCommit() error { + // Reset the current patch if there is one. + if !self.c.Git().Patch.PatchBuilder.IsEmpty() { + self.c.Git().Patch.PatchBuilder.Reset() + } + + if err := self.toggleSelection(); err != nil { + return err + } + + if self.c.Git().Patch.PatchBuilder.IsEmpty() { + return nil + } + + self.c.Helpers().PatchBuilding.Escape() + + return self.c.WithWaitingStatus(self.c.Tr.RebasingStatus, func(gocui.Task) error { + commitIndex := self.getPatchCommitIndex() + self.c.LogAction(self.c.Tr.Actions.RemovePatchFromCommit) + err := self.c.Git().Patch.DeletePatchesFromCommit(self.c.Model().Commits, commitIndex) + return self.c.Helpers().MergeAndRebase.CheckMergeOrRebase(err) + }) +} + +func (self *PatchBuildingController) getPatchCommitIndex() int { + for index, commit := range self.c.Model().Commits { + if commit.Hash() == self.c.Git().Patch.PatchBuilder.To { + return index + } + } + return -1 +} + func (self *PatchBuildingController) Escape() error { context := self.c.Contexts().CustomPatchBuilder state := context.GetState() diff --git a/pkg/i18n/english.go b/pkg/i18n/english.go index 8d66d546a..cf70b3e0b 100644 --- a/pkg/i18n/english.go +++ b/pkg/i18n/english.go @@ -300,6 +300,8 @@ type TranslationSet struct { ToggleSelectHunkTooltip string HunkStagingHint string ToggleSelectionForPatch string + RemoveSelectionFromPatch string + RemoveSelectionFromPatchTooltip string EditHunk string EditHunkTooltip string ToggleStagingView string @@ -688,6 +690,9 @@ type TranslationSet struct { BranchUnknown string DiscardChangeTitle string DiscardChangePrompt string + DiscardLinesFromCommitTitle string + DiscardLinesFromCommitPrompt string + DiscardLinesFromCommitPromptWithReset string CreateNewBranchFromCommit string BuildingPatch string ViewCommits string @@ -1009,6 +1014,7 @@ type Actions struct { ResolveConflictByDeletingFile string NotEnoughContextToStage string NotEnoughContextToDiscard string + NotEnoughContextToRemoveLines string NotEnoughContextForCustomPatch string IgnoreExcludeFile string IgnoreFileErr string @@ -1407,6 +1413,8 @@ func EnglishTranslationSet() *TranslationSet { ToggleSelectHunkTooltip: "Toggle line-by-line vs. hunk selection mode.", HunkStagingHint: englishHunkStagingHint, ToggleSelectionForPatch: `Toggle lines in patch`, + RemoveSelectionFromPatch: `Remove lines from commit`, + RemoveSelectionFromPatchTooltip: "Remove the selected lines from this commit. This runs an interactive rebase in the background, so you may get a merge conflict if a later commit also changes these lines.", EditHunk: `Edit hunk`, EditHunkTooltip: "Edit selected hunk in external editor.", ToggleStagingView: "Switch view", @@ -1798,6 +1806,9 @@ func EnglishTranslationSet() *TranslationSet { BranchUnknown: "Branch unknown", DiscardChangeTitle: "Discard change", DiscardChangePrompt: "Are you sure you want to discard this change (git reset)? It is irreversible.\nTo disable this dialogue set the config key of 'gui.skipDiscardChangeWarning' to true", + DiscardLinesFromCommitTitle: "Discard lines from commit", + DiscardLinesFromCommitPrompt: "Are you sure you want to discard the selected lines from this commit?", + DiscardLinesFromCommitPromptWithReset: "Are you sure you want to discard the selected lines from this commit?\n\nNote: This will reset the active custom patch!", CreateNewBranchFromCommit: "Create new branch off of commit", BuildingPatch: "Building patch", ViewCommits: "View commits", @@ -2079,6 +2090,7 @@ func EnglishTranslationSet() *TranslationSet { ResolveConflictByDeletingFile: "Resolve by deleting file", NotEnoughContextToStage: "Staging or unstaging changes is not possible with a diff context size of 0. Increase the context using '%s'.", NotEnoughContextToDiscard: "Discarding changes is not possible with a diff context size of 0. Increase the context using '%s'.", + NotEnoughContextToRemoveLines: "Removing lines from a commit is not possible with a diff context size of 0. Increase the context using '%s'.", NotEnoughContextForCustomPatch: "Creating custom patches is not possible with a diff context size of 0. Increase the context using '%s'.", IgnoreExcludeFile: "Ignore or exclude file", IgnoreFileErr: "Cannot ignore .gitignore", diff --git a/pkg/integration/tests/patch_building/discard_lines_from_commit.go b/pkg/integration/tests/patch_building/discard_lines_from_commit.go new file mode 100644 index 000000000..ab1414053 --- /dev/null +++ b/pkg/integration/tests/patch_building/discard_lines_from_commit.go @@ -0,0 +1,63 @@ +package patch_building + +import ( + "github.com/jesseduffield/lazygit/pkg/config" + . "github.com/jesseduffield/lazygit/pkg/integration/components" +) + +var DiscardLinesFromCommit = NewIntegrationTest(NewIntegrationTestArgs{ + Description: "Discard specific lines from a commit using the 'd' shortcut in the patch building view", + ExtraCmdArgs: []string{}, + Skip: false, + SetupConfig: func(config *config.AppConfig) {}, + SetupRepo: func(shell *Shell) { + shell.EmptyCommit("first commit") + + shell.CreateFileAndAdd("file1", "1st line\n2nd line\n3rd line\n") + shell.Commit("commit to remove from") + }, + Run: func(t *TestDriver, keys config.KeybindingConfig) { + t.Views().Commits(). + Focus(). + Lines( + Contains("commit to remove from").IsSelected(), + Contains("first commit"), + ). + PressEnter() + + t.Views().CommitFiles(). + IsFocused(). + Lines( + Contains("A file1").IsSelected(), + ). + PressEnter() + + // Select the second line (+2nd line) and press 'd' to remove it + t.Views().PatchBuilding(). + IsFocused(). + SelectNextItem(). + SelectedLines( + Contains("+2nd line"), + ). + Press(keys.Universal.Remove) + + t.ExpectPopup().Confirmation(). + Title(Equals("Discard lines from commit")). + Content(Equals("Are you sure you want to discard the selected lines from this commit?")). + Confirm() + + // After the rebase, we should be back at the commit files view + // and the commit should now only contain the 1st and 3rd lines + t.Views().CommitFiles(). + IsFocused(). + Lines( + Contains("A file1").IsSelected(), + ). + PressEscape() + + t.Views().Main().ContainsLines( + Equals("+1st line"), + Equals("+3rd line"), + ) + }, +}) diff --git a/pkg/integration/tests/test_list.go b/pkg/integration/tests/test_list.go index 4d9edaa70..804a8764f 100644 --- a/pkg/integration/tests/test_list.go +++ b/pkg/integration/tests/test_list.go @@ -328,6 +328,7 @@ var tests = []*components.IntegrationTest{ patch_building.ApplyInReverseWithConflict, patch_building.ApplyWithModifiedFileConflict, patch_building.ApplyWithModifiedFileNoConflict, + patch_building.DiscardLinesFromCommit, patch_building.EditLineInPatchBuildingPanel, patch_building.MoveRangeToIndex, patch_building.MoveToEarlierCommit, From 5b6a8a304e3914b980c33f5580adb04501a736cb Mon Sep 17 00:00:00 2001 From: Jesse Duffield Date: Sat, 7 Mar 2026 20:44:56 +1100 Subject: [PATCH 7/7] Prevent patch building panel from briefly appearing when discarding change from commit --- pkg/gui/controllers/patch_building_controller.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pkg/gui/controllers/patch_building_controller.go b/pkg/gui/controllers/patch_building_controller.go index f20173d53..4d418d7df 100644 --- a/pkg/gui/controllers/patch_building_controller.go +++ b/pkg/gui/controllers/patch_building_controller.go @@ -224,13 +224,13 @@ func (self *PatchBuildingController) discardSelectionFromCommit() error { return nil } - self.c.Helpers().PatchBuilding.Escape() - - return self.c.WithWaitingStatus(self.c.Tr.RebasingStatus, func(gocui.Task) error { + return self.c.WithWaitingStatusSync(self.c.Tr.RebasingStatus, func() error { commitIndex := self.getPatchCommitIndex() self.c.LogAction(self.c.Tr.Actions.RemovePatchFromCommit) err := self.c.Git().Patch.DeletePatchesFromCommit(self.c.Model().Commits, commitIndex) - return self.c.Helpers().MergeAndRebase.CheckMergeOrRebase(err) + self.c.Helpers().PatchBuilding.Escape() + return self.c.Helpers().MergeAndRebase.CheckMergeOrRebaseWithRefreshOptions( + err, types.RefreshOptions{Mode: types.SYNC}) }) }