Re: [PATCH 5/5] diff: store graph prefix buf in git_graph struct
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Oct 3, 2024, 23:43 UTC
- Message-ID
- <xmqq7caohhw3.fsf@gitster.g>
- In-Reply-To
- <20241003211317.GE11328@coredump.intra.peff.net>
Jeff King <peff@peff.net> writes:
Show 15 quoted lines
> Since we only need the strbuf when we are formatting graph padding, we
> can give ownership of the strbuf to the git_graph struct, letting us
> free it when that struct is no longer in use.
>
> static const char *diff_output_prefix_callback(struct diff_options *opt, void *data)
> {
> struct git_graph *graph = data;
> - static struct strbuf msgbuf = STRBUF_INIT;
>
> assert(opt);
>
> if (!graph)
> return opt->line_prefix;
>
> - strbuf_reset(&msgbuf);Oooh, I love this change. The fewer file scope statics (or global states in general) we have, the better ;-).