All of lore.kernel.org
 help / color / mirror / Atom feed
From: Taylor Blau <me@ttaylorr.com>
To: Chris Down <chris@chrisdown.name>
Cc: git@vger.kernel.org, Junio C Hamano <gitster@pobox.com>,
	Johannes Schindelin <johannes.schindelin@gmx.de>,
	Christian Couder <chriscool@tuxfamily.org>,
	kernel-team@fb.com
Subject: Re: [PATCH v2 2/2] bisect: output bisect setup status in bisect log
Date: Mon, 9 May 2022 11:41:34 -0400	[thread overview]
Message-ID: <Ynk2LrMyHIKyK63i@nand.local> (raw)
In-Reply-To: <YnTz6mbP2UDrsTaL@chrisdown.name>

On Fri, May 06, 2022 at 11:09:46AM +0100, Chris Down wrote:
> > 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.
>
> There was some discussion in the v1 thread (Message-ID:
> <xmqqv8uo1mk6.fsf@gitster.g>) about adding an additional `git bisect status'
> command, but while writing it my immediate thoughts were that it doesn't
> make much sense to separate from the rest of the log. I'm curious what
> Junio's thoughts are on that, happy to do it whichever way is preferred. :-)

I don't have a strong feeling either way. The way that you have
incorporated it into the output of "git bisect log" feels simple and
sane to me.

The most important thing is that you didn't break the ability to pipe
the unmodified output of "git bisect log" into "git bisect replay", so I
beyond that I don't have any strong feelings about it.

> > > Signed-off-by: Chris Down <chris@chrisdown.name>
> > > ---
> > >  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).
>
> I'm not intimately familiar with the codebase, so maybe I'm missing
> something, but isn't it overkill to use a string buffer for something which
> is isn't going to then be used as a mutable buffer?
>
> Happy to do it whichever way works for you folks, but would be good to
> understand the rationale so that I can write better patches next time :-)

I'm trying to avoid having a vsnprintf() when one isn't strictly needed.
This part of bisect isn't performance critical code, so having a strbuf
around doesn't bother me in the slightest.

If you really wanted to, you could treat the strbuf like a static buffer
by declaring it as such and calling strbuf_reset() before or after using
it. But allocating little bits of memory in bisect_print_status()
doesn't bother me much, either.

At the very least, it would dramatically simplify the implementation of
this patch with a negligible cost, so I'd recommend doing it.

> > >  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?
>
> Not sure I understand, we printf() in bisect_log_printf, no?

I missed that, thanks for pointing it out.

Thanks,
Taylor

  reply	other threads:[~2022-05-09 15:41 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-06  0:52 [PATCH v2 0/2] bisect: status improvements when bisect is not fully fleshed out Chris Down
2022-05-06  0:52 ` [PATCH v2 1/2] bisect: output state before we are ready to compute bisection Chris Down
2022-05-06  2:52   ` Taylor Blau
2022-05-06 10:14     ` Chris Down
2022-05-06 16:42     ` Junio C Hamano
2022-05-06 18:12   ` Junio C Hamano
2022-05-06  0:52 ` [PATCH v2 2/2] bisect: output bisect setup status in bisect log Chris Down
2022-05-06  3:03   ` Taylor Blau
2022-05-06 10:09     ` Chris Down
2022-05-09 15:41       ` Taylor Blau [this message]
2022-05-06 16:57     ` Junio C Hamano
2022-05-06 16:47   ` Junio C Hamano
2022-05-06 18:18   ` Junio C Hamano
2022-05-09 15:43     ` Taylor Blau
2022-05-09 16:08       ` Junio C Hamano
2022-05-09 16:27         ` Taylor Blau
2022-05-07 10:58 ` [PATCH v2 0/2] bisect: status improvements when bisect is not fully fleshed out Chris Down
2022-05-07 18:25   ` Junio C Hamano
2022-05-07 21:22     ` Chris Down

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=Ynk2LrMyHIKyK63i@nand.local \
    --to=me@ttaylorr.com \
    --cc=chris@chrisdown.name \
    --cc=chriscool@tuxfamily.org \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=johannes.schindelin@gmx.de \
    --cc=kernel-team@fb.com \
    /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.