From: Diogo Castro Date: Fri, 02 Oct 2026 21:52:53 GMT Subject: Re: [PATCH] dir: fix negative pathspecs in 'git ls-files' and 'git add' Message-ID: In-Reply-To: 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 wrote: > > Diogo Castro 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. >