All of lore.kernel.org
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Johannes Sixt <j6t@kdbg.org>
Cc: Johannes Schindelin via GitGitGadget <gitgitgadget@gmail.com>,
	git@vger.kernel.org, Phillip Wood <phillip.wood@talktalk.net>
Subject: Re: [PATCH 3/2] rebase -i: recognize short commands without arguments
Date: Fri, 26 Oct 2018 10:26:25 +0900	[thread overview]
Message-ID: <xmqq1s8dfqgu.fsf@gitster-ct.c.googlers.com> (raw)
In-Reply-To: <fff6fec5-88c9-4125-bf51-5e96e34bf1f6@kdbg.org> (Johannes Sixt's message of "Thu, 25 Oct 2018 22:47:45 +0200")

Johannes Sixt <j6t@kdbg.org> writes:

> 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.

  reply	other threads:[~2018-10-26  1:26 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-10-03 15:00 [PATCH 0/1] rebase -i: introduce the 'break' command Johannes Schindelin via GitGitGadget
2018-10-03 15:00 ` [PATCH 1/1] " Johannes Schindelin via GitGitGadget
2018-10-05  8:15   ` Junio C Hamano
2018-10-05  8:36     ` Jacob Keller
2018-10-05 15:36     ` Johannes Schindelin
2018-10-09  3:59       ` Junio C Hamano
2018-10-09  5:27         ` Junio C Hamano
2018-10-10  8:53 ` [PATCH v2 0/2] " Johannes Schindelin via GitGitGadget
2018-10-10  8:53   ` [PATCH v2 1/2] rebase -i: clarify what happens on a failed `exec` Johannes Schindelin via GitGitGadget
2018-10-10  9:46     ` Eric Sunshine
2018-10-11  8:15       ` Junio C Hamano
2018-10-12  8:36         ` Johannes Schindelin
2018-10-10  8:53   ` [PATCH v2 2/2] rebase -i: introduce the 'break' command Johannes Schindelin via GitGitGadget
2018-10-11  9:08     ` Phillip Wood
2018-10-12  8:35       ` Johannes Schindelin
2018-10-12 11:09         ` Phillip Wood
2018-10-12 11:24           ` Johannes Schindelin
2018-10-12 13:14   ` [PATCH v3 0/2] " Johannes Schindelin via GitGitGadget
2018-10-12 13:14     ` [PATCH v3 1/2] rebase -i: clarify what happens on a failed `exec` Johannes Schindelin via GitGitGadget
2018-10-12 13:14     ` [PATCH v3 2/2] rebase -i: introduce the 'break' command Johannes Schindelin via GitGitGadget
2018-10-12 14:09       ` Junio C Hamano
2018-10-12 15:31         ` Johannes Schindelin
2018-10-12 14:01     ` [PATCH v3 0/2] " Junio C Hamano
2018-10-12 15:32       ` Johannes Schindelin
2018-10-25 20:47     ` [PATCH 3/2] rebase -i: recognize short commands without arguments Johannes Sixt
2018-10-26  1:26       ` Junio C Hamano [this message]
2018-10-26  8:04       ` Johannes Schindelin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=xmqq1s8dfqgu.fsf@gitster-ct.c.googlers.com \
    --to=gitster@pobox.com \
    --cc=git@vger.kernel.org \
    --cc=gitgitgadget@gmail.com \
    --cc=j6t@kdbg.org \
    --cc=phillip.wood@talktalk.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.