Skip to content

Commit

Permalink
rebase -i: recognize short commands without arguments
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
j6t authored and gitster committed Oct 26, 2018
1 parent 71f8246 commit 3a4a4ca
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
3 changes: 2 additions & 1 deletion sequencer.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion t/lib-rebase.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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";;
Expand Down
4 changes: 3 additions & 1 deletion t/t3418-rebase-continue.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 3a4a4ca

Please sign in to comment.