jesseduffield/lazygit · info
Patch is still empty. Add some files or lines to your patch
Error message
Patch is still empty. Add some files or lines to your patch first.
What it means
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.
Source
Thrown at pkg/gui/controllers/custom_patch_options_menu_action.go:26
"github.com/jesseduffield/lazygit/pkg/commands/models"
"github.com/jesseduffield/lazygit/pkg/gocui"
"github.com/jesseduffield/lazygit/pkg/gui/controllers/helpers"
"github.com/jesseduffield/lazygit/pkg/gui/types"
"github.com/jesseduffield/lazygit/pkg/utils"
"github.com/samber/lo"
)
type CustomPatchOptionsMenuAction struct {
c *ControllerCommon
}
func (self *CustomPatchOptionsMenuAction) Call() error {
if !self.c.Git().Patch.PatchBuilder.Active() {
return errors.New(self.c.Tr.NoPatchError)
}
if self.c.Git().Patch.PatchBuilder.IsEmpty() {
return errors.New(self.c.Tr.EmptyPatchError)
}
menuItems := []*types.MenuItem{
{
Label: self.c.Tr.ResetPatch,
Tooltip: self.c.Tr.ResetPatchTooltip,
OnPress: self.c.Helpers().PatchBuilding.Reset,
Keys: menuKey('c'),
},
{
Label: self.c.Tr.ApplyPatch,
Tooltip: self.c.Tr.ApplyPatchTooltip,
OnPress: func() error { return self.handleApplyPatch(false) },
Keys: menuKey('a'),
},
{
Label: self.c.Tr.ApplyPatchInReverse,
Tooltip: self.c.Tr.ApplyPatchInReverseTooltip,View on GitHub (pinned to c477a2959b)
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
Defensive patterns
Strategy: validation
Validate before calling
// Require a non-empty patch before the options menu:
if !patchBuilder.Active() || patchBuilder.IsEmpty() {
return errors.New("add files or lines to the patch first")
} Prevention
- 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
When it happens
Trigger: 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.
Common situations: Iterating on a partial patch selection and accidentally emptying it; stale patch state from a previous session in the same repo view.
Related errors
- No patch created yet. To start building a patch, use 'space'
- Cannot change context while in patch building mode because w
- No config file found
- Cannot change the rename similarity threshold while in patch
- {{disabledReason.Text}}
AI-assisted analysis of jesseduffield/lazygit@c477a2959b (2026-08-15).
Data as JSON: /api/errors/9baf8104707f49d4.
Report an issue: GitHub.