Re: [PATCH] dir: fix negative pathspecs in 'git ls-files' and 'git add'
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Aug 30, 2026, 22:58 UTC
- Message-ID
- <xmqqmru3z051.fsf@gitster.g>
- In-Reply-To
- <CAJw8QBPbxangB90DceDXxaDmyz8fn5jbEUihhe2faJrZ3o7BeQ@mail.gmail.com>
Diogo Castro <dc@diogocastro.com> writes:
Show 13 quoted lines
> 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.