Skip to content

Commit 3a4a4ca

Browse files
j6tgitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 71f8246 commit 3a4a4ca

File tree

3 files changed

+6
-3
lines changed

3 files changed

+6
-3
lines changed

sequencer.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1954,7 +1954,8 @@ static int parse_insn_line(struct todo_item *item, const char *bol, char *eol)
19541954
if (skip_prefix(bol, todo_command_info[i].str, &bol)) {
19551955
item->command = i;
19561956
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) {
19581959
bol++;
19591960
item->command = i;
19601961
break;

t/lib-rebase.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ set_fake_editor () {
4949
case $line in
5050
squash|fixup|edit|reword|drop)
5151
action="$line";;
52-
exec*|break)
52+
exec*|break|b)
5353
echo "$line" | sed 's/_/ /g' >> "$1";;
5454
"#")
5555
echo '# comment' >> "$1";;

t/t3418-rebase-continue.sh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,9 @@ unset GIT_SEQUENCE_EDITOR
243243

244244
test_expect_success 'the todo command "break" works' '
245245
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 &&
247249
test_path_is_missing execed &&
248250
git rebase --continue &&
249251
test_path_is_file execed

0 commit comments

Comments
 (0)