From: Johannes Sixt Date: Thu, 25 Oct 2018 20:47:45 +0000 (+0200) Subject: rebase -i: recognize short commands without arguments X-Git-Tag: v2.20.0-rc0~83^2 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/3a4a4cab3ef024e10af7a5bbcaed4b961c60f1db rebase -i: recognize short commands without arguments The sequencer instruction 'b', short for 'break', is rejected: error: invalid line 2: b The reason is that the parser expects all short commands to have an argument. Permit short commands without arguments. Signed-off-by: Johannes Sixt Signed-off-by: Junio C Hamano --- diff --git a/sequencer.c b/sequencer.c index ee3961ec63..3107f59ea7 100644 --- a/sequencer.c +++ b/sequencer.c @@ -1954,7 +1954,8 @@ static int parse_insn_line(struct todo_item *item, const char *bol, char *eol) if (skip_prefix(bol, todo_command_info[i].str, &bol)) { item->command = i; break; - } else if (bol[1] == ' ' && *bol == todo_command_info[i].c) { + } else if ((bol + 1 == eol || bol[1] == ' ') && + *bol == todo_command_info[i].c) { bol++; item->command = i; break; diff --git a/t/lib-rebase.sh b/t/lib-rebase.sh index 584604ee63..86572438ec 100644 --- a/t/lib-rebase.sh +++ b/t/lib-rebase.sh @@ -49,7 +49,7 @@ set_fake_editor () { case $line in squash|fixup|edit|reword|drop) action="$line";; - exec*|break) + exec*|break|b) echo "$line" | sed 's/_/ /g' >> "$1";; "#") echo '# comment' >> "$1";; diff --git a/t/t3418-rebase-continue.sh b/t/t3418-rebase-continue.sh index 185a491089..b282505aac 100755 --- a/t/t3418-rebase-continue.sh +++ b/t/t3418-rebase-continue.sh @@ -243,7 +243,9 @@ unset GIT_SEQUENCE_EDITOR test_expect_success 'the todo command "break" works' ' rm -f execed && - FAKE_LINES="break exec_>execed" git rebase -i HEAD && + FAKE_LINES="break b exec_>execed" git rebase -i HEAD && + test_path_is_missing execed && + git rebase --continue && test_path_is_missing execed && git rebase --continue && test_path_is_file execed