rebase -i: recognize short commands without arguments
authorJohannes Sixt <j6t@kdbg.org>
Thu, 25 Oct 2018 20:47:45 +0000 (22:47 +0200)
committerJunio C Hamano <gitster@pobox.com>
Fri, 26 Oct 2018 01:20:23 +0000 (10:20 +0900)
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>
sequencer.c
t/lib-rebase.sh
t/t3418-rebase-continue.sh
index ee3961ec63a0b34c29a1b253bb2106c56f57c79e..3107f59ea700bdb37e4d32bb035bf959aa6b3497 100644 (file)
@@ -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;
index 584604ee63bd193795daa0f9ca4ad62d9a84b197..86572438ec7832d96c24012dba7842bceb5a85cf 100644 (file)
@@ -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";;
index 185a49108924ddad58c2ea75304a4fe4506c298d..b282505aaceb3dbe11f8348b7c9b41dcdab27a8f 100755 (executable)
@@ -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