git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH 3/2] rebase -i: recognize short commands without arguments

From
Junio C Hamano <gitster@pobox.com>
Date
Oct 26, 2018, 01:26 UTC
Message-ID
<xmqq1s8dfqgu.fsf@gitster-ct.c.googlers.com>
In-Reply-To
<fff6fec5-88c9-4125-bf51-5e96e34bf1f6@kdbg.org>
Johannes Sixt <j6t@kdbg.org> writes:
Show 55 quoted lines
> 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>
> ---
>  I'll send a another patch in a moment that tests all short
>  sequencer commands, but it is independent from this topic.
>
>  sequencer.c                | 3 ++-
>  t/lib-rebase.sh            | 2 +-
>  t/t3418-rebase-continue.sh | 4 +++-
>  3 files changed, 6 insertions(+), 3 deletions(-)
>
> 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 &&

When first 'break' hits, "git rebase -i" shouldn't have exited with non-zero, and we get to see if execed is there (it shouldn't exist yet).

> +	git rebase --continue &&

And then we continue, to hit the next 'b', which shouldn't barf, either, and then

>  	test_path_is_missing execed &&

we make sure execed is not yet there, before continuing out of that that 'b'roken state

>  	git rebase --continue &&
and then we'll hit the exec to create that file.
>  	test_path_is_file execed
Makes sense.  Thanks.
Previous: Johannes SixtNext: Johannes Schindelin
Message 26 of 27 in “rebase -i: introduce the 'break' command”
  1. 0/1 rebase -i: introduce the 'break' commandJohannes Schindelin via GitGitGadget, Oct 3, 2018
  2. 1/1 rebase -i: introduce the 'break' commandJohannes Schindelin via GitGitGadget, Oct 3, 2018
  3. Junio C HamanoOct 5, 2018
  4. Jacob KellerOct 5, 2018
  5. Johannes SchindelinOct 5, 2018
  6. Junio C HamanoOct 9, 2018
  7. Junio C HamanoOct 9, 2018
  8. 0/2 rebase -i: introduce the 'break' commandJohannes Schindelin via GitGitGadget, Oct 10, 2018
  9. 1/2 rebase -i: clarify what happens on a failed `exec`Johannes Schindelin via GitGitGadget, Oct 10, 2018
  10. Eric SunshineOct 10, 2018
  11. Junio C HamanoOct 11, 2018
  12. Johannes SchindelinOct 12, 2018
  13. 2/2 rebase -i: introduce the 'break' commandJohannes Schindelin via GitGitGadget, Oct 10, 2018
  14. Phillip WoodOct 11, 2018
  15. Johannes SchindelinOct 12, 2018
  16. Phillip WoodOct 12, 2018
  17. Johannes SchindelinOct 12, 2018
  18. 0/2 rebase -i: introduce the 'break' commandJohannes Schindelin via GitGitGadget, Oct 12, 2018
  19. 1/2 rebase -i: clarify what happens on a failed `exec`Johannes Schindelin via GitGitGadget, Oct 12, 2018
  20. 2/2 rebase -i: introduce the 'break' commandJohannes Schindelin via GitGitGadget, Oct 12, 2018
  21. Junio C HamanoOct 12, 2018
  22. Johannes SchindelinOct 12, 2018
  23. Junio C HamanoOct 12, 2018
  24. Johannes SchindelinOct 12, 2018
  25. 3/2 rebase -i: recognize short commands without argumentsJohannes Sixt, Oct 25, 2018
  26. Junio C HamanoOct 26, 2018
  27. Johannes SchindelinOct 26, 2018

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.