git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] dir: fix negative pathspecs in 'git ls-files' and 'git add'

From
Diogo Castro <dc@diogocastro.com>
Date
Oct 2, 2026, 21:52 UTC
Message-ID
<CAJw8QBOnpkXAG3i6BGL6nKeyPgssr9-qJ9vdgH_MhYJi9VhrMQ@mail.gmail.com>
In-Reply-To
<xmqqv78qw3hc.fsf@gitster.g>
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.
>
Previous: Junio C Hamano
Message 7 of 7 in “dir: fix negative pathspecs in 'git ls-files' and 'git add'”
  1. dir: fix negative pathspecs in 'git ls-files' and 'git add'Diogo Castro via GitGitGadget, Aug 28, 2026
  2. Junio C HamanoAug 28, 2026
  3. Diogo CastroAug 30, 2026
  4. Junio C HamanoAug 30, 2026
  5. Diogo CastroAug 31, 2026
  6. Junio C HamanoAug 31, 2026
  7. Diogo CastroOct 2, 2026

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.