]> git.ipfire.org Git - thirdparty/git.git/commit
rebase -i: improve error message when picking merge
authorPhillip Wood <phillip.wood@dunelm.org.uk>
Thu, 30 May 2024 13:43:50 +0000 (13:43 +0000)
committerJunio C Hamano <gitster@pobox.com>
Thu, 30 May 2024 17:02:58 +0000 (10:02 -0700)
commit4c063c82e9611ffd31353ababa96a0a39d9d7d85
treedf70d7d1b61e8cd0174592f8e6addba401527280
parent0c26738aa4a8256b40a46476c2433c03a562124f
rebase -i: improve error message when picking merge

The only todo commands that accept a merge commit are "merge" and
"reset". All the other commands like "pick" or "reword" fail when they
try to pick a a merge commit and print the message

    error: commit abc123 is a merge but no -m option was given.

followed by a hint about the command being rescheduled. This message is
designed to help the user when they cherry-pick a merge and forget to
pass "-m". For users who are rebasing the message is confusing as there
is no way for rebase to cherry-pick the merge.

Improve the user experience by detecting the error and printing some
advice on how to fix it when the todo list is parsed rather than waiting
for the "pick" command to fail. The advice recommends "merge" rather
than "exec git cherry-pick -m ..." on the assumption that cherry-picking
merges is relatively rare and it is more likely that the user chose
"pick" by a mistake.

It would be possible to support cherry-picking merges by allowing the
user to pass "-m" to "pick" commands but that adds complexity to do
something that can already be achieved with

    exec git cherry-pick -m1 abc123

Reported-by: Stefan Haller <lists@haller-berlin.de>
Signed-off-by: Phillip Wood <phillip.wood@dunelm.org.uk>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Documentation/config/advice.txt
advice.c
advice.h
sequencer.c
t/t3404-rebase-interactive.sh