Git development
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Diogo Castro <diogo.filipe.acastro@gmail.com>
Cc: Diogo Castro <dcastro@diogocastro.com>,
	 Diogo Castro via GitGitGadget <gitgitgadget@gmail.com>,
	 "git@vger.kernel.org" <git@vger.kernel.org>,
	Thomas Haller <thaller@redhat.com>,  Jeff King <peff@peff.net>
Subject: Re: [PATCH] dir: fix negative pathspecs in 'git ls-files' and 'git add'
Date: Mon, 31 Aug 2026 11:26:39 -0700	[thread overview]
Message-ID: <xmqqv78qw3hc.fsf@gitster.g> (raw)
In-Reply-To: <CAJw8QBMmv=zLN6sd_W9uQMF3H6Baatyq=TogLyZSFXK2gN4V8w@mail.gmail.com> (Diogo Castro's message of "Mon, 31 Aug 2026 15:30:22 +0100")

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.


      reply	other threads:[~2026-08-31 18:26 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-28 20:35 [PATCH] dir: fix negative pathspecs in 'git ls-files' and 'git add' Diogo Castro via GitGitGadget
2026-08-28 21:37 ` Junio C Hamano
2026-08-30 14:57   ` Diogo Castro
2026-08-30 22:58     ` Junio C Hamano
     [not found]     ` <a8955129fcb7478f9739c8586c6975e1@CWXP265MB5784.GBRP265.PROD.OUTLOOK.COM>
2026-08-31 14:30       ` Diogo Castro
2026-08-31 18:26         ` Junio C Hamano [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=xmqqv78qw3hc.fsf@gitster.g \
    --to=gitster@pobox.com \
    --cc=dcastro@diogocastro.com \
    --cc=diogo.filipe.acastro@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitgitgadget@gmail.com \
    --cc=peff@peff.net \
    --cc=thaller@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox