From: "René Scharfe" <l.s.r@web.de>
To: Git Mailing List <git@vger.kernel.org>
Cc: Junio C Hamano <gitster@pobox.com>
Subject: [PATCH] log-tree: always use return value of strbuf_detach()
Date: Sun, 25 Aug 2019 14:53:26 +0200 [thread overview]
Message-ID: <dc471768-7f42-3e51-6397-1c40466d3726@web.de> (raw)
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).
log-tree.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
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);
}
/*
--
2.23.0
next reply other threads:[~2019-08-25 12:53 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-08-25 12:53 René Scharfe [this message]
2019-08-26 18:46 ` [PATCH] log-tree: always use return value of strbuf_detach() Jeff King
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=dc471768-7f42-3e51-6397-1c40466d3726@web.de \
--to=l.s.r@web.de \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.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.
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).