From 7f9bfaec08a226ab910594b015e1c715402d49d7 Mon Sep 17 00:00:00 2001 From: Stefan Haller Date: Sat, 21 Feb 2026 14:31:14 +0100 Subject: [PATCH] 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