Re: [PATCH v2] rebase -x: sanity check command
- From
Johannes Schindelin <johannes.schindelin@gmx.de>
- Date
- Jan 30, 2019, 12:25 UTC
- Message-ID
- <nycvar.QRO.7.76.6.1901301325370.41@tvgsbejvaqbjf.bet>
- In-Reply-To
- <20190129184327.30391-1-phillip.wood@talktalk.net>
Hi Phillip,
On Tue, 29 Jan 2019, Phillip Wood wrote:
Show 43 quoted lines
> Range-diff against v1:
> 1: 9626549aec ! 1: 726b84c300 rebase -x: sanity check command
> @@ -2,8 +2,9 @@
>
> rebase -x: sanity check command
>
> - If the user gives an empty argument to --exec then the rebase starts to
> - run before erroring out with
> + If the user gives an empty argument to --exec then git creates a todo
> + list that it cannot parse. The rebase starts to run before erroring out
> + with
>
> error: missing arguments for exec
> error: invalid line 2: exec
> @@ -33,21 +34,16 @@
>
> +static int check_exec_cmd(const char *cmd)
> +{
> -+ int non_blank = 0;
> ++ if (strchr(cmd, '\n'))
> ++ return error(_("exec commands cannot contain newlines"));
> +
> -+ while (*cmd) {
> -+ if (*cmd == '\n')
> -+ return error(_("exec commands cannot contain newlines"));
> -+ if (!isspace(*cmd))
> -+ non_blank = 1;
> -+ cmd++;
> -+ }
> ++ /* Does the command consist purely of whitespace? */
> ++ if (!cmd[strspn(cmd, " \t\r\f\v")])
> ++ return error(_("empty exec command"));
> +
> -+ if (non_blank)
> -+ return 0;
> -+
> -+ return error(_("empty exec command"));
> ++ return 0;
> +}
> ++
> +
> int cmd_rebase(int argc, const char **argv, const char *prefix)
> {Looks great!
Thanks, Dscho