Re: [PATCH v3 4/8] builtin/commit-graph.c: extract 'read_one_commit()'
- From
Jeff King <peff@peff.net>
- Date
- May 14, 2020, 17:56 UTC
- Message-ID
- <20200514175646.GA2430834@coredump.intra.peff.net>
- In-Reply-To
- <c37e94907b140f3d2e5a44293f2c1faa6d473712.1589407014.git.me@ttaylorr.com>
On Wed, May 13, 2020 at 03:59:41PM -0600, Taylor Blau wrote:
Show 9 quoted lines
> @@ -209,44 +220,35 @@ static int graph_write(int argc, const char **argv)
> return 0;
> }
>
> - string_list_init(&lines, 0);
> - if (opts.stdin_packs || opts.stdin_commits) {
> - struct strbuf buf = STRBUF_INIT;
> + struct strbuf buf = STRBUF_INIT;
> + if (opts.stdin_packs) {This is a decl-after-statement, isn't it? It should fail with DEVELOPER=1.
The strbuf could be local in each block of the conditional, though that makes your cleanup label trickier. Only the stdin_commits side needs to clean up the buf, so we could just do it there. Or I'd be OK with having the strbuf declared at the top of the function, and using the whole-function cleanup label.
-Peff