Message ID | dc471768-7f42-3e51-6397-1c40466d3726@web.de (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | log-tree: always use return value of strbuf_detach() | expand |
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
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); } /*
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(-) -- 2.23.0