Subject: Re: [PATCH] ref-filter: fix stale parsed objects

From: Junio C Hamano <[email-masked]>
Date: Tue, 04 Nov 2025 10:31:14 -0800

Patrick Steinhardt <[email-masked]> writes:

> In 054f5f457e (ref-filter: parse objects on demand, 2025-10-23) we have
> started to skip parsing some objects in case we don't need to access
> their values in the first place. This was done by introducing a new
> member `struct expand_data::maybe_object` that gets populated on demand
> via `get_or_parse_object()`.
>
> This has led to a regression though where the object now gets reused
> because we don't reset it properly. The `oi` structure is declared in
> global scope, and there is no single place where we reset it before
> invoking `get_object()`. The consequence is that the `maybe_object`
> member doesn't get reset across calls, so subsequent calls will end up
> reusing the same object.
>
> This is only an issue for a subset of retrieved values, as not all of
> the infrastructure ends up calling `get_or_parse_object()`. So the
> effect is limited, which is probably why the issue wasn't detected
> earlier.
>
> Fix the issue by resetting `maybe_object` in `get_object()`.
>
> Reported-by: Junio C Hamano <[email-masked]>
> Based-on-patch-by: Jeff King <[email-masked]>
> Signed-off-by: Patrick Steinhardt <[email-masked]>
> ---
> As reported by Junio in <[email-masked]>. This applies
> directly on top of ps/ref-peeled-tags at 054f5f457e (ref-filter: parse
> objects on demand, 2025-10-23)
>
> Thanks!

Thanks.  As we stop reusing a stale maybe_object and instead start
parsing the right object when we need to, I wondered if the "on
demand" commit needs a new benchmark, but the example cited in the
message used %(raw) so it would not be affected, I guess.

Queued.  Thanks.