Subject: Re: [PATCH] ref-filter: handle nested tags in --points-at option

From: Junio C Hamano <[email-masked]>
Date: Wed, 05 Jul 2023 10:16:17 -0700

Jeff King <[email-masked]> writes:

> On Tue, Jul 04, 2023 at 11:10:47PM -0700, Junio C Hamano wrote:
>
>> My preference would be to see these optimization done first and then
>> add this new loop on top of it.  That way, we can measure more
>> easily what kind of additional overhead, if any, we are paying by
>> adding the loop.
>
> I ended up doing them on top, rather than before, but I think the size
> of the impact can easily be seen.

Ah, I should have first read (or at least skimmed) all messages
before responding.  Thanks for following through.

> The one thing that would actually make us a lot faster (by using the
> packed-refs peels) is to make full peels the only option, and do not
> bother letting --points-at match "B" in an A->B->C peel. But that would
> be removing something that is currently matched (even before the patch
> in this thread), so I stopped short of it in my optimizations.

Interesting.  Right now, if I create a 'direct' tag that points
directly at HEAD, and then create an 'indirect' tag that points at
'direct', i.e.

    $ git tag -a -m 'a direct tag to HEAD' direct HEAD
    $ git tag -a -m 'an indirect tag' indirect direct

I would get a piece of advice message that encourages to correct the
mistake with "git tag -f indirect direct^{}".  Then I ask for tags
that point at HEAD, I see only 'direct' and not 'indirect'.  Your
optimization would start showing both 'direct' and 'indirect' if
they are packed.  But you are correct to worry about the opposite
case.  If I ask for tags that point at 'direct', I currently see
'indirect', but of course 'indirect' will not appear as the peeled
value of any ref, and the optimized version will stop saying that
'indirect' is a ref that points at 'direct'.  That sounds like a
regression.

> But even
> if we decide to do that, Jan's patch is not making anything worse there
> (in fact, it is making it better, because it is matching "C" which we do
> not currently match).
> ...
> So I'd be inclined to proceed with the patches I sent earlier, and then
> if we choose to later refactor again to drop "B", we can.

We generally avoid taking away anything once we give it to users;
once the patch under discussion goes in, there is no taking it back,
i.e. the new _behaviour_ closes the door to certain optimizations.

I do not at all mind to see us decide and declare that it is a good
thing to say that not just 'direct' but also 'indirect' points at
HEAD, and that 'indirect' points at 'direct' and the patch under
discussion makes the world a etter place, and we will not regret
that decision.  But the time to make such a decision is now, before
we give a go-ahead to the patch.

Thanks.