I see this work has been incorporated into [1]
I'm closing the PR on git/git.
[1]: https://lore.kernel.org/git/81EC0E28-13E7-4D10-BD07-3601124CBD77@ytausch.de/T/#t
On Mon, 31 Aug 2026 at 19:26, Junio C Hamano <gitster@pobox.com> wrote:
Show 23 quoted lines
>
> Diogo Castro <diogo.filipe.acastro@gmail.com> writes:
>
> > My point was that computing the common prefix across both positive
> > *and* negative pathspecs would not improve performance, and might
> > actually make it worse.
>
> OK. Then that points at the right solution. Ignore negative ones
> when finding what the common prefix is, strip it only from positive
> ones to reduce the width of the traversal to come up with the list
> of possible match candidates, and match them as full paths against
> the negative ones to cull "within the positive set but is excluded"
> paths, and the posted patch looks good.
>
> I still wonder if we need different implementation when we have many
> more negative patterns than the positive ones. In such a case, the
> stage to filter paths that matched one positive pattern by finding
> matches with a negative pattern among many of them, which may
> benefit from having a similar common prefix (among negative
> patterns) optimization, but that is a separate topic.
>
> Thanks.
>