Skip to content

Commit 45c0cbb

Browse files
committed
Allow removing a worktree in a bare repo
1 parent 7f0341c commit 45c0cbb

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

lua/neogit/popups/worktree/actions.lua

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,8 +129,9 @@ function M.delete()
129129
local success = false
130130

131131
if input.get_permission(("Remove worktree at %q?"):format(selected)) then
132-
if change_dir and status.is_open() then
133-
status.instance():chdir(git.worktree.main().path)
132+
local main = git.worktree.main() -- A bare repo has no main, so check
133+
if change_dir and status.is_open() and main then
134+
status.instance():chdir(main.path)
134135
end
135136

136137
-- This might produce some error messages that need to get suppressed

0 commit comments

Comments
 (0)