Re: [PATCH v3 08/10] builtin/diff-index: learn --merge-base
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Sep 18, 2020, 05:11 UTC
- Message-ID
- <xmqqk0wroehv.fsf@gitster.c.googlers.com>
- In-Reply-To
- <20200917181303.GA108156@coredump.intra.peff.net>
Jeff King <peff@peff.net> writes:
Show 17 quoted lines
> On Thu, Sep 17, 2020 at 10:28:53AM -0700, Junio C Hamano wrote:
>
>> > - if (diff_cache(revs, &ent->item->oid, ent->name, !!(option & DIFF_INDEX_CACHED)))
>> > +
>> > + if (option & DIFF_INDEX_MERGE_BASE) {
>> > + diff_get_merge_base(revs, &oid);
>> > + name = xstrdup(oid_to_hex(&oid));
>>
>> Leak?
>
> 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);
>
> -PeffYes, I was debating myself if I should mention it or trust/assume that the contributor can easily figure it out.