Subject: Re: [PATCH] odb: do not use "blank" substitute for NULL

From: Patrick Steinhardt <[email-masked]>
Date: Thu, 18 Dec 2025 07:31:32 +0100

On Thu, Dec 18, 2025 at 12:35:40PM +0900, Junio C Hamano wrote:
> When various *object_info() functions are given an extended object
> info structure as NULL by a caller that does not want any details,
> the code uses a file-scope static blank_oi to pass it down to the
> helper functions they use, to avoid handling NULL specifically.
> 
> The ps/object-read-stream topic graduated to 'master' recently
> however had a bug that assumed that two identically named file-scope
> static variables in two functions are the same, which of course is
> not the case.  This made "git commit" take 0.38 seconds to 1508
> seconds in some case, as reported by Aaron Plattner here:
> 
>   https://lore.kernel.org/git/[email-masked]/
> 
> We _could_ move the blank_oi variable to a global scope in BSS to
> fix this regression, but explicitly handling the NULL is a much
> safer fix.  It would also reduce the chance of errors that somebody
> accidentally writes into blank_oi, making its contents dirty, which
> potentially will make subsequent calls into the callpath misbehave.
> 
> By explicitly handling NULL input, we no longer have to worry about
> it.

Thanks for handling this, Junio!

I've sent out an alternative fix via a patch series that I already had
cooking locally in [1]. It also goes a bit further than your series as
it also recognizes the case where the caller passes a blank object info
again.

That series also contains some other fixes related to reading object
info where we had been inconsistent with returned results, and another
performance improvement where we can skip unpacking packed objects.

I'm happy to go either route though -- I can hold off my series for a
bit longer and rebase it on top of your fix, or we replace your fix with
my series. Just let me know your preference.

Thanks!

Patrick

[1]: <202[email-masked]>