summaryrefslogtreecommitdiffstats
path: root/pkg/commands/git.go
diff options
context:
space:
mode:
authorJesse Duffield <jessedduffield@gmail.com>2020-08-27 17:00:43 +1000
committerJesse Duffield <jessedduffield@gmail.com>2020-08-27 21:51:07 +1000
commitf99d5f74d49109c19f7701005e636a38c9a70fdb (patch)
tree1bd6d6ca761ceec37f10935fdf7405a9277c6464 /pkg/commands/git.go
parent30a066aa41cedabeebac0f9e747073ff33805893 (diff)
drop merge commits when interactive rebasing just like git CLI
Diffstat (limited to 'pkg/commands/git.go')
-rw-r--r--pkg/commands/git.go16
1 files changed, 12 insertions, 4 deletions
diff --git a/pkg/commands/git.go b/pkg/commands/git.go
index c671c0b5f..3f671b9ff 100644
--- a/pkg/commands/git.go
+++ b/pkg/commands/git.go
@@ -910,7 +910,8 @@ func (c *GitCommand) PrepareInteractiveRebaseCommand(baseSha string, todo string
debug = "TRUE"
}
- splitCmd := str.ToArgv(fmt.Sprintf("git rebase --interactive --autostash --keep-empty --rebase-merges %s", baseSha))
+ cmdStr := fmt.Sprintf("git rebase --interactive --autostash --keep-empty %s", baseSha)
+ splitCmd := str.ToArgv(cmdStr)
cmd := c.OSCommand.command(splitCmd[0], splitCmd[1:]...)
@@ -962,11 +963,18 @@ func (c *GitCommand) GenerateGenericRebaseTodo(commits []*Commit, actionIndex in
todo := ""
for i, commit := range commits[0:baseIndex] {
- a := "pick"
+ var commitAction string
if i == actionIndex {
- a = action
+ commitAction = action
+ } else if commit.IsMerge {
+ // your typical interactive rebase will actually drop merge commits by default. Damn git CLI, you scary!
+ // doing this means we don't need to worry about rebasing over merges which always causes problems.
+ // you typically shouldn't be doing rebases that pass over merge commits anyway.
+ commitAction = "drop"
+ } else {
+ commitAction = "pick"
}
- todo = a + " " + commit.Sha + " " + commit.Name + "\n" + todo
+ todo = commitAction + " " + commit.Sha + " " + commit.Name + "\n" + todo
}
return todo, commits[baseIndex].Sha, nil