Re: [PATCH v2 2/2] bisect: output bisect setup status in bisect log

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, May 06, 2022 at 01:52:54AM +0100, Chris Down wrote:
> This allows seeing the current intermediate status without adding a new
> good or bad commit:
>
>     $ git bisect log | tail -1
>     # status: waiting for bad commit, 1 good commit known

Hmm. I was worried that this would make it harder to turn the output of
"git bisect log" into something you can inject into "git bisect replay
<log>". But it doesn't, because you prefix the status lines with a '#'
character.

That's good, and I think it's an improvement over what I'd currently
recommend, which would be something like:

    git bisect log | grep '^# bad:'
    git bisect log | grep '^# good:'

to see the state of our good and bad endpoints.

I'm not totally convinced it _needs_ to live in "git bisect log",
though, since it feels like additional information that is just added
for convenience. That's not the worst thing in the world, but I think
it would be fine to just take the first patch (with my suggestions
applied) as well.

> Signed-off-by: Chris Down <chris@xxxxxxxxxxxxxx>
> ---
>  builtin/bisect--helper.c    | 25 ++++++++++++++++++++-----
>  t/t6030-bisect-porcelain.sh |  9 +++++++--
>  2 files changed, 27 insertions(+), 7 deletions(-)
>
> diff --git a/builtin/bisect--helper.c b/builtin/bisect--helper.c
> index 9d583f651c..ef75f0a0ce 100644
> --- a/builtin/bisect--helper.c
> +++ b/builtin/bisect--helper.c
> @@ -404,6 +404,21 @@ static struct bisect_state bisect_status(const struct bisect_terms *terms)
>  	return bs;
>  }
>
> +__attribute__((format (printf, 1, 2)))
> +static void bisect_log_printf(const char *fmt, ...)
> +{
> +	va_list ap;
> +	char buf[1024];
> +
> +	va_start(ap, fmt);
> +	if (vsnprintf(buf, sizeof(buf), fmt, ap) < 0)
> +		*buf = '\0';
> +	va_end(ap);
> +
> +	printf("%s", buf);
> +	append_to_file(git_path_bisect_log(), "# %s", buf);
> +}

This direct use of vsnprintf might be avoided by preparing the output in
bisect_print_status() via a strbuf and then calling:

    append_to_file(git_path_bisect_log(), "# %s", buf.buf).

>  static void bisect_print_status(const struct bisect_terms *terms)
>  {
>  	const struct bisect_state bs = bisect_status(terms);
> @@ -413,13 +428,13 @@ static void bisect_print_status(const struct bisect_terms *terms)
>  		return;
>
>  	if (!bs.nr_good && !bs.nr_bad)
> -		printf(_("status: waiting for both good and bad commits\n"));
> +		bisect_log_printf(_("status: waiting for both good and bad commits\n"));
>  	else if (bs.nr_good)
> -		printf(Q_("status: waiting for bad commit, %d good commit known\n",
> -			  "status: waiting for bad commit, %d good commits known\n",
> -			  bs.nr_good), bs.nr_good);
> +		bisect_log_printf(Q_("status: waiting for bad commit, %d good commit known\n",
> +				     "status: waiting for bad commit, %d good commits known\n",
> +				     bs.nr_good), bs.nr_good);
>  	else
> -		printf(_("status: waiting for good commit(s), bad commit known\n"));
> +		bisect_log_printf(_("status: waiting for good commit(s), bad commit known\n"));
>  }

Interesting; this patch removes the output that we were giving to users
in the last patch. Should it go to both places?

Thanks,
Taylor



[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux