diff --git a/lua/neogit/lib/git/cherry_pick.lua b/lua/neogit/lib/git/cherry_pick.lua index bffd7526..f02c4405 100644 --- a/lua/neogit/lib/git/cherry_pick.lua +++ b/lua/neogit/lib/git/cherry_pick.lua @@ -1,6 +1,7 @@ local git = require("neogit.lib.git") local notification = require("neogit.lib.notification") local util = require("neogit.lib.util") +local client = require("neogit.client") ---@class NeogitGitCherryPick local M = {} @@ -10,7 +11,15 @@ local function fire_cherrypick_event(data) end function M.pick(commits, args) - local result = git.cli["cherry-pick"].arg_list(util.merge(args, commits)).call { await = true } + local cmd = git.cli["cherry-pick"].arg_list(util.merge(args, commits)) + + local result + if vim.tbl_contains(args, "--edit") then + result = cmd.env(client.get_envs_git_editor()).call { pty = true } + else + result = cmd.call { await = true } + end + if result.code ~= 0 then notification.error("Cherry Pick failed. Resolve conflicts before continuing") else diff --git a/lua/neogit/popups/cherry_pick/init.lua b/lua/neogit/popups/cherry_pick/init.lua index fbef4d2a..180d476a 100644 --- a/lua/neogit/popups/cherry_pick/init.lua +++ b/lua/neogit/popups/cherry_pick/init.lua @@ -7,18 +7,25 @@ local M = {} function M.create(env) local in_progress = git.sequencer.pick_or_revert_in_progress() - -- TODO - -- :switch("x", "x", "Reference cherry in commit message", { cli_prefix = "-" }) - -- :switch("e", "edit", "Edit commit messages", false) - -- :switch("s", "signoff", "Add Signed-off-by lines", false) - -- :option("m", "mainline", "", "Replay merge relative to parent") - -- :option("s", "strategy", "", "Strategy") - -- :option("S", "gpg-sign", "", "Sign using gpg") - local p = popup .builder() :name("NeogitCherryPickPopup") - :switch_if(not in_progress, "F", "ff", "Attempt fast-forward", { enabled = true }) + :option_if(not in_progress, "m", "mainline", "", "Replay merge relative to parent", { key_prefix = "-" }) + :option_if(not in_progress, "s", "strategy", "", "Strategy", { + key_prefix = "=", + choices = { "octopus", "ours", "resolve", "subtree", "recursive" }, + }) + :switch_if( + not in_progress, + "F", + "ff", + "Attempt fast-forward", + { enabled = true, incompatible = { "edit" } } + ) + :switch_if(not in_progress, "x", "x", "Reference cherry in commit message", { cli_prefix = "-" }) + :switch_if(not in_progress, "e", "edit", "Edit commit messages", { incompatible = { "ff" } }) + :switch_if(not in_progress, "s", "signoff", "Add Signed-off-by lines") + :option_if(not in_progress, "S", "gpg-sign", "", "Sign using gpg", { key_prefix = "-" }) :group_heading_if(not in_progress, "Apply here") :action_if(not in_progress, "A", "Pick", actions.pick) :action_if(not in_progress, "a", "Apply", actions.apply) diff --git a/lua/neogit/popups/merge/init.lua b/lua/neogit/popups/merge/init.lua index 2ef0ef1f..8ec36b80 100644 --- a/lua/neogit/popups/merge/init.lua +++ b/lua/neogit/popups/merge/init.lua @@ -15,7 +15,7 @@ function M.create(env) :switch_if(not in_merge, "f", "ff-only", "Fast-forward only", { incompatible = { "no-ff" } }) :switch_if(not in_merge, "n", "no-ff", "No fast-forward", { incompatible = { "ff-only" } }) :option_if(not in_merge, "s", "strategy", "", "Strategy", { - choices = { "resolve", "recursive", "octopus", "ours", "subtree" }, + choices = { "octopus", "ours", "resolve", "subtree", "recursive" }, key_prefix = "-", }) :option_if(not in_merge, "X", "strategy-option", "", "Strategy Option", {