Re: [PATCH v3 08/10] builtin/diff-index: learn --merge-base
- From
Jeff King <peff@peff.net>
- Date
- Sep 18, 2020, 18:12 UTC
- Message-ID
- <20200918181217.GB187490@coredump.intra.peff.net>
- In-Reply-To
- <xmqqk0wroehv.fsf@gitster.c.googlers.com>
On Thu, Sep 17, 2020 at 10:11:56PM -0700, Junio C Hamano wrote:
Show 10 quoted lines
> > Using oid_to_hex_r() avoids an extra copy, and the leak goes away too: > > > > char merge_base_hex[GIT_MAX_HEXSZ + 1]; > > ... > > name = oid_to_hex_r(merge_base_hex, &oid); > > > > -Peff > > Yes, I was debating myself if I should mention it or trust/assume > that the contributor can easily figure it out.
I was tempted to call "xstrdup(oid_to_hex())" an anti-pattern, but looking at most of the other calls, they really do want a new string that lasts longer than a stack variable.
And even the stack ones are a bit ugly in that you have to know to size things correctly.
So I lost my enthusiasm to crusade against it. ;)
-Peff