Remove the "Select parent commit" prompt when reverting a merge commit

In pretty much 100% of the cases, you want to use -m1, so spare users the
complexity of a confusing prompt.

See
https://public-inbox.org/git/e60a8b1a-98c8-4ac7-b966-ff9635bb781d@haller-berlin.de/
for some discussion.
This commit is contained in:
Stefan Haller 2025-03-30 11:54:40 +02:00
parent c13c6356e3
commit f14a3cdd46
4 changed files with 12 additions and 51 deletions

View file

@ -285,15 +285,14 @@ func (self *CommitCommands) ShowFileContentCmdObj(hash string, filePath string)
return self.cmd.New(cmdArgs).DontLog()
}
// Revert reverts the selected commit by hash
func (self *CommitCommands) Revert(hash string) error {
cmdArgs := NewGitCmd("revert").Arg(hash).ToArgv()
return self.cmd.New(cmdArgs).Run()
}
func (self *CommitCommands) RevertMerge(hash string, parentNumber int) error {
cmdArgs := NewGitCmd("revert").Arg(hash, "-m", fmt.Sprintf("%d", parentNumber)).
// Revert reverts the selected commit by hash. If isMerge is true, we'll pass -m 1
// to say we want to revert the first parent of the merge commit, which is the one
// people want in 99.9% of cases. In current git versions we could unconditionally
// pass -m 1 even for non-merge commits, but older versions of git choke on it.
func (self *CommitCommands) Revert(hash string, isMerge bool) error {
cmdArgs := NewGitCmd("revert").
Arg(hash).
ArgIf(isMerge, "-m", "1").
ToArgv()
return self.cmd.New(cmdArgs).Run()