diff --git a/pkg/gui/controllers/commits_files_controller.go b/pkg/gui/controllers/commits_files_controller.go index 0cea2bd46..3e8849d88 100644 --- a/pkg/gui/controllers/commits_files_controller.go +++ b/pkg/gui/controllers/commits_files_controller.go @@ -153,6 +153,10 @@ func (self *CommitFilesController) checkout(node *filetree.CommitFileNode) error } func (self *CommitFilesController) discard(node *filetree.CommitFileNode) error { + if node.File == nil { + return self.c.ErrorMsg(self.c.Tr.DiscardNotSupportedForDirectory) + } + if ok, err := self.c.Helpers().PatchBuilding.ValidateNormalWorkingTreeState(); !ok { return err } diff --git a/pkg/i18n/english.go b/pkg/i18n/english.go index 22a00b91c..4025c6e9d 100644 --- a/pkg/i18n/english.go +++ b/pkg/i18n/english.go @@ -268,6 +268,7 @@ type TranslationSet struct { DiscardOldFileChange string DiscardFileChangesTitle string DiscardFileChangesPrompt string + DiscardNotSupportedForDirectory string DisabledForGPG string CreateRepo string BareRepo string @@ -955,6 +956,7 @@ func EnglishTranslationSet() TranslationSet { DiscardOldFileChange: "Discard this commit's changes to this file", DiscardFileChangesTitle: "Discard file changes", DiscardFileChangesPrompt: "Are you sure you want to discard this commit's changes to this file? If this file was created in this commit, it will be deleted", + DiscardNotSupportedForDirectory: "Discarding changes is not supported for entire directories. Please use a custom patch for this.", DisabledForGPG: "Feature not available for users using GPG", 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) ",