From: Tian Yuchen <a3205153416@gmail.com>
To: "Remy D. Farley" <one-d-wide@protonmail.com>, git@vger.kernel.org
Subject: Re: Bug: git add :!x . exits with error when x is in .gitignore
Date: Tue, 3 Feb 2026 02:04:45 +0800 [thread overview]
Message-ID: <1d560aa1-d452-47f5-aaf2-4cb1ccdab100@gmail.com> (raw)
In-Reply-To: <20260131194309.601838-1-one-d-wide@protonmail.com>
On 2/1/26 03:43, Remy D. Farley wrote:
Thanks for the report and the patch! I also agree that the behavior you
described seems like a bug.
However, though I'm new to git community, I still have concerns about
the fix in 'dir.c':
> - if (!pathspec || !pathspec->nr)
> + if (!pathspec || !pathspec->nr || pathspec->magic & PATHSPEC_EXCLUDE)
> return 0;
I tried to analyze the logic and I believe this patch breaks the basic
functionality of the negative pathspec (:!):
(I didn't check the caller of exclude_matches_pathspec and I only focus
on the function itself. Tell me if I'm wrong :)
By returning 0 whenever PATHSPEC_EXCLUDE is set globally,
exclude_matches_pathspec will report "no match" for all files,
effectively disabling the exclusion mechanism entirely.
Instead of fixing the issue with ignored files, this patch causes valid
exclusions to be ignored.
We must check if the specific path matches the exclude pattern, not
short-circuit based on the global flag.
It will be great if we set a test script for this. I will be working on
it in the next few days.
Regards,
Yuchen
next prev parent reply other threads:[~2026-02-02 18:04 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-01-31 19:43 Bug: git add :!x . exits with error when x is in .gitignore Remy D. Farley
2026-02-02 18:04 ` Tian Yuchen [this message]
2026-02-02 21:25 ` Remy D. Farley
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=1d560aa1-d452-47f5-aaf2-4cb1ccdab100@gmail.com \
--to=a3205153416@gmail.com \
--cc=git@vger.kernel.org \
--cc=one-d-wide@protonmail.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