Skip to content

Commit d3fbf8b

Browse files
authored
Merge pull request #883 from star-szr/rebase-include-current-commit
2 parents 76182ae + 44aa55f commit d3fbf8b

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

lua/neogit/lib/git/cli.lua

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -483,6 +483,15 @@ local configurations = {
483483
},
484484
},
485485

486+
["rev-list"] = config {
487+
flags = {
488+
parents = "--parents",
489+
},
490+
options = {
491+
max_count = "--max-count",
492+
},
493+
},
494+
486495
["rev-parse"] = config {
487496
flags = {
488497
verify = "--verify",

lua/neogit/popups/rebase/actions.lua

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,15 @@ function M.interactively(popup)
6969
end
7070

7171
if commit then
72-
git.rebase.rebase_interactive(commit, popup:get_arguments())
72+
local args = popup:get_arguments()
73+
local parent_commit = git.cli["rev-list"].max_count(1).parents.args(commit).call().stdout[1]
74+
if commit ~= parent_commit then
75+
commit = vim.split(parent_commit, " ")[2]
76+
else
77+
table.insert(args, "--root")
78+
end
79+
80+
git.rebase.rebase_interactive(commit, args)
7381
end
7482
end
7583

0 commit comments

Comments
 (0)