From: Junio C Hamano <gitster@pobox.com>
To: Phillip Wood <phillip.wood123@gmail.com>
Cc: Piotr Siupa <piotrsiupa@gmail.com>, git@vger.kernel.org
Subject: Re: [BUG]: Non-matching exclude pathspec causes an error in empty repository when the flag "--update" is present
Date: Mon, 02 Jun 2025 08:31:50 -0700 [thread overview]
Message-ID: <xmqq34ciupll.fsf@gitster.g> (raw)
In-Reply-To: <e790367c-6777-4b4b-97f1-3b3a2cbdb177@gmail.com> (Phillip Wood's message of "Mon, 2 Jun 2025 11:07:17 +0100")
Phillip Wood <phillip.wood123@gmail.com> writes:
>> git add --update -- ':(exclude)foo'
>> This results in:
>> error: pathspec ':(exclude)foo' did not match any file(s) known to git
>> error: pathspec '.' did not match any file(s) known to git
> ...
> git add -u builtin ':(exclude)*.[ch]'
>
> which will never add any files (the builtin directory only contains
> '.c' and '.h' files). So I think maybe the bug is that we don't print
> an error when there are tracked files and an exclude pattern matches
> everything
I have to disagree here. The "did not match" error is telling you
this:
You tried to tell me that you wanted to add something, but you
didn't enumerate what to add in concrete terms. You instead
gave me pathspec, so I tried to see if there are paths that
match these patterns. This pattern did not produce any match
so out of this pattern came no additions (even though other
patterns may have contributed to other additions).
I think the "'.' did not match any file(s)" in the first example
makes perfect sense, but complaining about negative patterns that
did not match does not make much sense to me. If I said
git add -- \*.c ':!auto-generated.c'
and there is no auto-generated.c file (yet) in this working tree,
that is a happy outcome. I didn't want to add it, even if it
existed, and it turned out to be missing. It would become annoying
pretty quickly if we started complaining a pattern in .gitignore
that did not match anything, and complaining against "you gave me an
exclude pathspec pattern that matched nothing" feels pretty similar
to me.
Thanks.
next prev parent reply other threads:[~2025-06-02 15:31 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-05-27 8:14 [BUG]: Non-matching exclude pathspec causes an error in empty repository when the flag "--update" is present Piotr Siupa
2025-06-02 10:07 ` Phillip Wood
2025-06-02 15:31 ` Junio C Hamano [this message]
2025-06-10 9:41 ` Piotr Siupa
2025-06-10 9:45 ` Piotr Siupa
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=xmqq34ciupll.fsf@gitster.g \
--to=gitster@pobox.com \
--cc=git@vger.kernel.org \
--cc=phillip.wood123@gmail.com \
--cc=piotrsiupa@gmail.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;
as well as URLs for NNTP newsgroup(s).