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 <j6t@kdbg.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Johannes Sixt committed Oct 25, 2018 at 22:47 UTC 3a4a4cab3ef024e10af7a5bbcaed4b961c60f1db
3 files changed +6 -3
sequencer.c
+2 -1
@@ -1954,7 +1954,8 @@ static int parse_insn_line(struct todo_item *item, const char *bol, char *eol)
1954 if (skip_prefix(bol, todo_command_info[i].str, &bol)) {
1955 item->command = i;
1956 break;
1957 - } else if (bol[1] == ' ' && *bol == todo_command_info[i].c) {
1957 + } else if ((bol + 1 == eol || bol[1] == ' ') &&
1958 + *bol == todo_command_info[i].c) {
1959 bol++;
1960 item->command = i;
1961 break;
t/lib-rebase.sh
+1 -1
@@ -49,7 +49,7 @@ set_fake_editor () {
49 case $line in
50 squash|fixup|edit|reword|drop)
51 action="$line";;
52 - exec*|break)
52 + exec*|break|b)
53 echo "$line" | sed 's/_/ /g' >> "$1";;
54 "#")
55 echo '# comment' >> "$1";;
t/t3418-rebase-continue.sh
+3 -1
@@ -243,7 +243,9 @@ unset GIT_SEQUENCE_EDITOR
243
244 test_expect_success 'the todo command "break" works' '
245 rm -f execed &&
246 - FAKE_LINES="break exec_>execed" git rebase -i HEAD &&
246 + FAKE_LINES="break b exec_>execed" git rebase -i HEAD &&
247 + test_path_is_missing execed &&
248 + git rebase --continue &&
249 test_path_is_missing execed &&
250 git rebase --continue &&
251 test_path_is_file execed