From 4d9ad47aa77835fd35431a0684e6670272455252 Mon Sep 17 00:00:00 2001 From: disrupted Date: Tue, 21 Jul 2026 10:37:32 +0200 Subject: [PATCH] fix: handle discard conflict with delete --- lua/neogit/buffers/status/actions.lua | 32 ++++++++++++++++++++------- 1 file changed, 24 insertions(+), 8 deletions(-) diff --git a/lua/neogit/buffers/status/actions.lua b/lua/neogit/buffers/status/actions.lua index 58d24f01c..7410e58b7 100644 --- a/lua/neogit/buffers/status/actions.lua +++ b/lua/neogit/buffers/status/actions.lua @@ -841,11 +841,19 @@ M.n_discard = function(self) input.get_choice("Discard conflict by taking...", { values = choices, default = #choices }) if choice == "o" then - git.cli.checkout.ours.files(selection.item.absolute_path).call { await = true } - git.status.stage { selection.item.name } + if selection.item.mode:sub(1, 1) == "D" then + git.cli.rm.files(selection.item.absolute_path).call { await = true } + else + git.cli.checkout.ours.files(selection.item.absolute_path).call { await = true } + git.status.stage { selection.item.name } + end elseif choice == "t" then - git.cli.checkout.theirs.files(selection.item.absolute_path).call { await = true } - git.status.stage { selection.item.name } + if selection.item.mode:sub(2, 2) == "D" then + git.cli.rm.files(selection.item.absolute_path).call { await = true } + else + git.cli.checkout.theirs.files(selection.item.absolute_path).call { await = true } + git.status.stage { selection.item.name } + end elseif choice == "c" then git.cli.checkout.merge.files(selection.item.absolute_path).call { await = true } git.status.stage { selection.item.name } @@ -872,11 +880,19 @@ M.n_discard = function(self) input.get_choice("Discard conflict by taking...", { values = choices, default = #choices }) if choice == "o" then - git.cli.checkout.ours.files(selection.item.absolute_path).call { await = true } - git.status.stage { selection.item.name } + if selection.item.mode:sub(1, 1) == "D" then + git.cli.rm.files(selection.item.absolute_path).call { await = true } + else + git.cli.checkout.ours.files(selection.item.absolute_path).call { await = true } + git.status.stage { selection.item.name } + end elseif choice == "t" then - git.cli.checkout.theirs.files(selection.item.absolute_path).call { await = true } - git.status.stage { selection.item.name } + if selection.item.mode:sub(2, 2) == "D" then + git.cli.rm.files(selection.item.absolute_path).call { await = true } + else + git.cli.checkout.theirs.files(selection.item.absolute_path).call { await = true } + git.status.stage { selection.item.name } + end elseif choice == "c" then git.cli.checkout.merge.files(selection.item.absolute_path).call { await = true } git.status.stage { selection.item.name }