{"record":{"id":"9baf8104707f49d4","repo":"jesseduffield/lazygit","slug":"patch-is-still-empty-add-some-files-or-lines-to-y","errorCode":null,"errorMessage":"Patch is still empty. Add some files or lines to your patch first.","messagePattern":"Patch is still empty\\. Add some files or lines to your patch first\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"info","filePath":"pkg/gui/controllers/custom_patch_options_menu_action.go","lineNumber":26,"sourceCode":"\t\"github.com/jesseduffield/lazygit/pkg/commands/models\"\n\t\"github.com/jesseduffield/lazygit/pkg/gocui\"\n\t\"github.com/jesseduffield/lazygit/pkg/gui/controllers/helpers\"\n\t\"github.com/jesseduffield/lazygit/pkg/gui/types\"\n\t\"github.com/jesseduffield/lazygit/pkg/utils\"\n\t\"github.com/samber/lo\"\n)\n\ntype CustomPatchOptionsMenuAction struct {\n\tc *ControllerCommon\n}\n\nfunc (self *CustomPatchOptionsMenuAction) Call() error {\n\tif !self.c.Git().Patch.PatchBuilder.Active() {\n\t\treturn errors.New(self.c.Tr.NoPatchError)\n\t}\n\n\tif self.c.Git().Patch.PatchBuilder.IsEmpty() {\n\t\treturn errors.New(self.c.Tr.EmptyPatchError)\n\t}\n\n\tmenuItems := []*types.MenuItem{\n\t\t{\n\t\t\tLabel:   self.c.Tr.ResetPatch,\n\t\t\tTooltip: self.c.Tr.ResetPatchTooltip,\n\t\t\tOnPress: self.c.Helpers().PatchBuilding.Reset,\n\t\t\tKeys:    menuKey('c'),\n\t\t},\n\t\t{\n\t\t\tLabel:   self.c.Tr.ApplyPatch,\n\t\t\tTooltip: self.c.Tr.ApplyPatchTooltip,\n\t\t\tOnPress: func() error { return self.handleApplyPatch(false) },\n\t\t\tKeys:    menuKey('a'),\n\t\t},\n\t\t{\n\t\t\tLabel:   self.c.Tr.ApplyPatchInReverse,\n\t\t\tTooltip: self.c.Tr.ApplyPatchInReverseTooltip,","sourceCodeStart":8,"sourceCodeEnd":44,"githubUrl":"https://github.com/jesseduffield/lazygit/blob/c477a2959b229fbf3284be0d4d2904ab61ec3c94/pkg/gui/controllers/custom_patch_options_menu_action.go#L8-L44","documentation":"Thrown by CustomPatchOptionsMenuAction.Call when the patch builder is Active() but IsEmpty(). This happens when a patch was started (files/lines were added at some point) but everything was subsequently removed — e.g. you toggled off the last file or all the selected lines — leaving an active-but-empty patch. The menu refuses to operate on an empty patch because applying or copying it is meaningless.","triggerScenarios":"Adding a file/lines to the patch builder, then removing them all (toggling off with 'space' or deselecting lines), and pressing the custom patch options key without resetting the patch.","commonSituations":"Iterating on a partial patch selection and accidentally emptying it; stale patch state from a previous session in the same repo view.","solutions":["Re-add at least one file ('space' on a commit file) or line range to the patch","Or reset the patch entirely and start a fresh selection"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// Require a non-empty patch before the options menu:\nif !patchBuilder.Active() || patchBuilder.IsEmpty() {\n    return errors.New(\"add files or lines to the patch first\")\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Reset the patch when you remove its last item, so state never lingers empty-but-active","Check both Active() and IsEmpty() before patch operations","Show patch line/file counts in the UI so emptiness is visible before invoking the menu"],"tags":["lazygit","patch-building","empty-patch","menu-guard"],"backgroundTag":null,"analyzedSha":"c477a2959b229fbf3284be0d4d2904ab61ec3c94","analyzedAt":"2026-08-15T08:34:32.451Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}