From: Junio C Hamano <gitster@pobox.com>
To: "Phillip Wood via GitGitGadget" <gitgitgadget@gmail.com>
Cc: git@vger.kernel.org,
Johannes Schindelin <johannes.schindelin@gmx.de>,
Phillip Wood <phillip.wood@dunelm.org.uk>
Subject: Re: [PATCH 1/2] rebase -i: match whole word in is_command()
Date: Thu, 23 Feb 2023 14:25:07 -0800 [thread overview]
Message-ID: <xmqq5ybs6mv0.fsf@gitster.g> (raw)
In-Reply-To: <b050e7c1a4daf6c65aa9b2b6f44248d7b403918e.1677185702.git.gitgitgadget@gmail.com> (Phillip Wood via GitGitGadget's message of "Thu, 23 Feb 2023 20:55:00 +0000")
"Phillip Wood via GitGitGadget" <gitgitgadget@gmail.com> writes:
> const char *str = todo_command_info[command].str;
> const char nick = todo_command_info[command].c;
> - const char *p = *bol + 1;
> + const char *p = *bol;
>
> - return skip_prefix(*bol, str, bol) ||
> - ((nick && **bol == nick) &&
> - (*p == ' ' || *p == '\t' || *p == '\n' || *p == '\r' || !*p) &&
> - (*bol = p));
> + return (skip_prefix(p, str, &p) || (nick && *p++ == nick)) &&
> + (*p == ' ' || *p == '\t' || *p == '\n' || *p == '\r' || !*p) &&
> + (*bol = p);
OK. So we skip the command name string in the line given by the
end-user (or see if the first letter matches the single letter
command) and make sure it is followed by a whitespace or EOL in
either case. The old code was not doing the "end of word" check
for the longhand at all, which was clearly wrong.
I too find "&& (*bol = p)" that pretends to be a Boolean condition
but is there only for its side effect distasteful, but I agree with
you that fixing it is outside the scope of this patch.
> @@ -2513,7 +2512,8 @@ static int parse_insn_line(struct repository *r, struct todo_item *item,
> break;
> }
> if (i >= TODO_COMMENT)
> - return -1;
> + return error(_("invalid command '%.*s'"),
> + (int)strcspn(bol, " \t\r\n"), bol);
Nice.
> diff --git a/t/lib-rebase.sh b/t/lib-rebase.sh
> index b57541356bd..1d2f0429aea 100644
> --- a/t/lib-rebase.sh
> +++ b/t/lib-rebase.sh
> @@ -60,7 +60,7 @@ set_fake_editor () {
> ">")
> echo >> "$1";;
> bad)
> - action="badcmd";;
> + action="pickled";;
;-)
next prev parent reply other threads:[~2023-02-23 22:25 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-02-23 20:54 [PATCH 0/2] sequencer parsing fixes Phillip Wood via GitGitGadget
2023-02-23 20:55 ` [PATCH 1/2] rebase -i: match whole word in is_command() Phillip Wood via GitGitGadget
2023-02-23 22:25 ` Junio C Hamano [this message]
2023-02-26 10:29 ` Jeff King
2023-02-23 20:55 ` [PATCH 2/2] rebase -i: fix parsing of "fixup -C<commit>" Phillip Wood via GitGitGadget
2023-02-23 22:35 ` Junio C Hamano
2023-02-24 14:02 ` [PATCH 0/2] sequencer parsing fixes Johannes Schindelin
2023-02-24 17:03 ` Junio C Hamano
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
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=xmqq5ybs6mv0.fsf@gitster.g \
--to=gitster@pobox.com \
--cc=git@vger.kernel.org \
--cc=gitgitgadget@gmail.com \
--cc=johannes.schindelin@gmx.de \
--cc=phillip.wood@dunelm.org.uk \
/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.
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).