From 71699bfe1d39e149432d35fe4cfea21d829687d5 Mon Sep 17 00:00:00 2001 From: Shu Nakamura Date: Wed, 26 Nov 2025 09:06:09 -0800 Subject: [PATCH] Fix: autosquash command (`r f`) bug is fixed. Obtain new base as the parent of currently specified commit, and run a interactive (autosquashing) rebase onto the commit. --- lua/neogit/popups/rebase/actions.lua | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/lua/neogit/popups/rebase/actions.lua b/lua/neogit/popups/rebase/actions.lua index 4076dd0dc..dcf5155d5 100644 --- a/lua/neogit/popups/rebase/actions.lua +++ b/lua/neogit/popups/rebase/actions.lua @@ -164,19 +164,22 @@ function M.edit() end function M.autosquash(popup) + local args = util.deduplicate(util.merge(popup:get_arguments(), { "--autosquash", "--keep-empty" })) local base if popup.state.env.commit and git.log.is_ancestor(popup.state.env.commit, "HEAD") then - base = popup.state.env.commit + local parent = git.log.parent(popup.state.env.commit) + if parent then + base = popup.state.env.commit .. "^" + else + base = popup.state.env.commit + table.insert(args, "--root") + end else base = git.rebase.merge_base_HEAD() end if base then - git.rebase.onto( - "HEAD", - base, - util.deduplicate(util.merge(popup:get_arguments(), { "--autosquash", "--keep-empty" })) - ) + git.rebase.rebase_interactive(base, args) end end