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

Re: [PATCH v2 3/4] bisect--helper: reimplement `bisect_run` shell function in C

From
Junio C Hamano <gitster@pobox.com>
Date
Apr 9, 2021, 06:15 UTC
Message-ID
<xmqq8s5snfv8.fsf@gitster.g>
In-Reply-To
<20210407173334.68222-4-mirucam@gmail.com>
Miriam Rubio <mirucam@gmail.com> writes:
Show 10 quoted lines
> +static int bisect_run(struct bisect_terms *terms, const char **argv, int argc)
> +{
> ...
> +	while (1) {
> +		strvec_clear(&args);
> +
> +		printf(_("running %s"), command.buf);
> +		res = run_command_v_opt(run_args.v, RUN_USING_SHELL);
> +
> +		if (res < 0 && res >= 128) {

Sorry for not noticing this total nonsense during my earlier review, but this condition will never trigger.

I would have noticed it if the style consistently used "order quantities from left to right, as if on a number line" convention, i.e.

		if (res < 0 && 128 <= res) {

Because there are only two valid range notation around a single variable, which are:

    (res < 0 || 128 <= res) - meaning 'res' is outside a span, or
    (0 <= res && res < 128) - meaning 'res' is inside a span.

and the above rewriten form is neither, it would have stood out as an error immediately.

Previous: Miriam R.Next: Miriam Rubio
Message 8 of 11 in “Finish converting git bisect to C part 4”
  1. 0/4 Finish converting git bisect to C part 4Miriam Rubio, Apr 7, 2021
  2. 1/4 run-command: make `exists_in_PATH()` non-staticMiriam Rubio, Apr 7, 2021
  3. Đoàn Trần Công DanhApr 8, 2021
  4. Junio C HamanoApr 8, 2021
  5. 3/4 bisect--helper: reimplement `bisect_run` shell function in CMiriam Rubio, Apr 7, 2021
  6. Junio C HamanoApr 7, 2021
  7. Miriam R.Apr 11, 2021
  8. Junio C HamanoApr 9, 2021
  9. 2/4 bisect--helper: reimplement `bisect_visualize()`shell function in CMiriam Rubio, Apr 7, 2021
  10. Junio C HamanoApr 7, 2021
  11. 4/4 bisect--helper: retire `--bisect-next-check` subcommandMiriam Rubio, Apr 7, 2021

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.