{"thread":{"id":"51728","subject":"[PATCH] log-tree: always use return value of strbuf_detach()","startedAt":"2019-08-25T12:53:36Z","lastAt":"2019-08-26T18:46:24Z","messageCount":2,"participants":["René Scharfe","Jeff King"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"381111","messageId":"dc471768-7f42-3e51-6397-1c40466d3726@web.de","threadId":"51728","inReplyTo":null,"subject":"[PATCH] log-tree: always use return value of strbuf_detach()","fromName":"René Scharfe","fromEmail":"l.s.r@web.de","sentAt":"2019-08-25T12:53:26Z","receivedAt":"2019-08-25T12:53:36Z","isPatch":true,"sender":{"key":"l.s.r@web.de","avatar":"https://avatars.githubusercontent.com/u/26122331?v=4"},"body":"strbuf_detach() has been returning a pointer to a buffer even for empty\nstrbufs since 08ad56f3f0 (\"strbuf: always return a non-NULL value from\nstrbuf_detach\", 2012-10-18).  Use that feature in show_log() instead of\nhaving it handle empty strbufs specially.\n\nSigned-off-by: René Scharfe <l.s.r@web.de>\n---\nThe patched code was added one day earlier, by ddf333f66c (\"pretty:\nprepare notes message at a centralized place\", 2012-10-17).\n\n log-tree.c | 4 +---\n 1 file changed, 1 insertion(+), 3 deletions(-)\n\ndiff --git a/log-tree.c b/log-tree.c\nindex 1e56df62a7..109c212224 100644\n--- a/log-tree.c\n+++ b/log-tree.c\n@@ -677,9 +677,7 @@ void show_log(struct rev_info *opt)\n \t\traw = (opt->commit_format == CMIT_FMT_USERFORMAT);\n \t\tformat_display_notes(&commit->object.oid, &notebuf,\n \t\t\t\t     get_log_output_encoding(), raw);\n-\t\tctx.notes_message = notebuf.len\n-\t\t\t? strbuf_detach(&notebuf, NULL)\n-\t\t\t: xcalloc(1, 1);\n+\t\tctx.notes_message = strbuf_detach(&notebuf, NULL);\n \t}\n\n \t/*\n--\n2.23.0\n"},{"id":"381234","messageId":"20190826184621.GE23399@sigill.intra.peff.net","threadId":"51728","inReplyTo":"dc471768-7f42-3e51-6397-1c40466d3726@web.de","subject":"Re: [PATCH] log-tree: always use return value of strbuf_detach()","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2019-08-26T18:46:21Z","receivedAt":"2019-08-26T18:46:24Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Sun, Aug 25, 2019 at 02:53:26PM +0200, René Scharfe wrote:\n\n> strbuf_detach() has been returning a pointer to a buffer even for empty\n> strbufs since 08ad56f3f0 (\"strbuf: always return a non-NULL value from\n> strbuf_detach\", 2012-10-18).  Use that feature in show_log() instead of\n> having it handle empty strbufs specially.\n> \n> Signed-off-by: René Scharfe <l.s.r@web.de>\n> ---\n> The patched code was added one day earlier, by ddf333f66c (\"pretty:\n> prepare notes message at a centralized place\", 2012-10-17).\n\nBad timing, I guess. :)\n\n> diff --git a/log-tree.c b/log-tree.c\n> index 1e56df62a7..109c212224 100644\n> --- a/log-tree.c\n> +++ b/log-tree.c\n> @@ -677,9 +677,7 @@ void show_log(struct rev_info *opt)\n>  \t\traw = (opt->commit_format == CMIT_FMT_USERFORMAT);\n>  \t\tformat_display_notes(&commit->object.oid, &notebuf,\n>  \t\t\t\t     get_log_output_encoding(), raw);\n> -\t\tctx.notes_message = notebuf.len\n> -\t\t\t? strbuf_detach(&notebuf, NULL)\n> -\t\t\t: xcalloc(1, 1);\n> +\t\tctx.notes_message = strbuf_detach(&notebuf, NULL);\n>  \t}\n\nYeah, this is definitely the right thing to do.\n\n-Peff\n"}]}