From: Phillip Wood <phillip.wood123@gmail.com>
To: 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, 2 Jun 2025 11:07:17 +0100 [thread overview]
Message-ID: <e790367c-6777-4b4b-97f1-3b3a2cbdb177@gmail.com> (raw)
In-Reply-To: <CAPM0=yCcOAGsUE8tX-o8ioihr+oWrORD6Tz=WH1OnmhpO+uqrA@mail.gmail.com>
Hi Piotr
On 27/05/2025 09:14, Piotr Siupa wrote:
> I found a regression in version 2.45.0. (It's still present in the
> current next - 2.49.0.1266.g31b7d2e469; earlier versions work fine.)
So it 2.44.0 there is no error message?
> When you run "git add --update" with an exclude pathspec on an empty
> repository, the command fails, showing an error about not being able
> to find the specified files.
> This happens only if the repository contains no files. Adding any
> files (even with "git add -N") or making a non-empty commit fixes the
> issue, regardless of whether the added files match the exclude
> pathspec or not.
>
> Way to reproduce:
> git init
> 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
I agree this is inconsistent with what happens if there are tracked
files but I wonder if it is actually better to print an error message
when an exclude pattern excludes all the files. We do print an error for
git add -u does-not-exist
because it does not match any file but not with
git add -u ':(exclude)*'
or
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
Best Wishes
Phillip
next prev parent reply other threads:[~2025-06-02 10:07 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 [this message]
2025-06-02 15:31 ` Junio C Hamano
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=e790367c-6777-4b4b-97f1-3b3a2cbdb177@gmail.com \
--to=phillip.wood123@gmail.com \
--cc=git@vger.kernel.org \
--cc=phillip.wood@dunelm.org.uk \
--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).