Git development
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Diogo Castro <dc@diogocastro.com>
Cc: Diogo Castro via GitGitGadget <gitgitgadget@gmail.com>,
	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: Sun, 30 Aug 2026 15:58:18 -0700	[thread overview]
Message-ID: <xmqqmru3z051.fsf@gitster.g> (raw)
In-Reply-To: <CAJw8QBPbxangB90DceDXxaDmyz8fn5jbEUihhe2faJrZ3o7BeQ@mail.gmail.com> (Diogo Castro's message of "Sun, 30 Aug 2026 15:57:27 +0100")

Diogo Castro <dc@diogocastro.com> writes:

> I don't think so.
>
> As far as I can tell, the "strip the common prefix" feature is a
> performance optimization aimed at avoiding walking the working
> directory needlessly.
> So for `git add -- a/b/c a/b/d`, there's no need to look anywhere
> other than in `a/b/`.
>
> But extending the "strip the common prefix" to negative pathspecs
> could end up negating the benefits we get from this perf optimization.
> E.g. in `git add -- a/b/c a/b/d ':!*.md'`, there is no prefix common
> to *all* pathspecs, so we'd revert to walking the entire working
> directory, even though `a/b/` would still suffice.

I was wondering more about case like this:

    $ git add -- a/b/c a/b/d ':!a/b/x

I agree that it is nonsense to compute the common prefix over only
positive ones, and then to strip the common prefix from both
positive and negative ones, and it needs to be corrected.

  reply	other threads:[~2026-08-30 22:58 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 [this message]
     [not found]     ` <a8955129fcb7478f9739c8586c6975e1@CWXP265MB5784.GBRP265.PROD.OUTLOOK.COM>
2026-08-31 14:30       ` Diogo Castro
2026-08-31 18:26         ` Junio C Hamano

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=xmqqmru3z051.fsf@gitster.g \
    --to=gitster@pobox.com \
    --cc=dc@diogocastro.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