rebase -i: fix parsing of "fixup -C<commit>"

If the user omits the space between "-C" and the commit in a fixup
command then it is parsed as an ordinary fixup and the commit message is
not updated as it should be. Fix this by making the space between "-C"
and "<commit>" optional as it is for the "merge" command.

Note that set_replace_editor() is changed to set $GIT_SEQUENCE_EDITOR
instead of $EDITOR in order to be able to replace the todo list and
reword commits with $FAKE_COMMIT_MESSAGE. This is safe as all the
existing users are using set_replace_editor() to replace the todo list.

Signed-off-by: Phillip Wood <phillip.wood@dunelm.org.uk>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Phillip Wood
2023-02-23 20:55:01 +00:00
committed by Junio C Hamano
parent 7aed2c0565
commit 666b6e1135
4 changed files with 42 additions and 6 deletions

View File

@ -2532,12 +2532,10 @@ static int parse_insn_line(struct repository *r, struct todo_item *item,
}
if (item->command == TODO_FIXUP) {
if (skip_prefix(bol, "-C", &bol) &&
(*bol == ' ' || *bol == '\t')) {
if (skip_prefix(bol, "-C", &bol)) {
bol += strspn(bol, " \t");
item->flags |= TODO_REPLACE_FIXUP_MSG;
} else if (skip_prefix(bol, "-c", &bol) &&
(*bol == ' ' || *bol == '\t')) {
} else if (skip_prefix(bol, "-c", &bol)) {
bol += strspn(bol, " \t");
item->flags |= TODO_EDIT_FIXUP_MSG;
}