From: Jeff King <peff@peff.net>
To: "René Scharfe" <l.s.r@web.de>
Cc: Git Mailing List <git@vger.kernel.org>,
Junio C Hamano <gitster@pobox.com>
Subject: Re: [PATCH] log-tree: always use return value of strbuf_detach()
Date: Mon, 26 Aug 2019 14:46:21 -0400 [thread overview]
Message-ID: <20190826184621.GE23399@sigill.intra.peff.net> (raw)
In-Reply-To: <dc471768-7f42-3e51-6397-1c40466d3726@web.de>
On Sun, Aug 25, 2019 at 02:53:26PM +0200, René Scharfe wrote:
> strbuf_detach() has been returning a pointer to a buffer even for empty
> strbufs since 08ad56f3f0 ("strbuf: always return a non-NULL value from
> strbuf_detach", 2012-10-18). Use that feature in show_log() instead of
> having it handle empty strbufs specially.
>
> Signed-off-by: René Scharfe <l.s.r@web.de>
> ---
> The patched code was added one day earlier, by ddf333f66c ("pretty:
> prepare notes message at a centralized place", 2012-10-17).
Bad timing, I guess. :)
> diff --git a/log-tree.c b/log-tree.c
> index 1e56df62a7..109c212224 100644
> --- a/log-tree.c
> +++ b/log-tree.c
> @@ -677,9 +677,7 @@ void show_log(struct rev_info *opt)
> raw = (opt->commit_format == CMIT_FMT_USERFORMAT);
> format_display_notes(&commit->object.oid, ¬ebuf,
> get_log_output_encoding(), raw);
> - ctx.notes_message = notebuf.len
> - ? strbuf_detach(¬ebuf, NULL)
> - : xcalloc(1, 1);
> + ctx.notes_message = strbuf_detach(¬ebuf, NULL);
> }
Yeah, this is definitely the right thing to do.
-Peff
prev parent reply other threads:[~2019-08-26 18:46 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-08-25 12:53 [PATCH] log-tree: always use return value of strbuf_detach() René Scharfe
2019-08-26 18:46 ` Jeff King [this message]
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=20190826184621.GE23399@sigill.intra.peff.net \
--to=peff@peff.net \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=l.s.r@web.de \
/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).