Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions lua/neogit/popups/rebase/actions.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is it even necessary to bring up the interactive editor view for this?

I think it would be even more convenient if this used the git.rebase.instantly path (similar to instant fixup).

Copy link
Copy Markdown
Contributor Author

@swnakamura swnakamura Feb 24, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the comment.
According to @loqusion, Magit runs git … rebase -i --root --autosquash --keep-empty --autostash when running r f, so I followed its behavior to show an interactive editor.

end
end

Expand Down
Loading