From: "René Scharfe" <l.s.r@web.de>
To: Sean Whitton <spwhitton@spwhitton.name>, git@vger.kernel.org
Cc: 81625@debbugs.gnu.org, Lester Longley <lester@ieee.org>,
Elijah Newren <newren@gmail.com>
Subject: Re: [BUG] 'git status --ignored' <pathspec> matches partial names
Date: Tue, 15 Sep 2026 17:54:36 +0200 [thread overview]
Message-ID: <ff9404bc-63e1-43bc-8419-9685f0bfa32d@web.de> (raw)
In-Reply-To: <87ld94klhf.fsf@athena.silentflame.com>
On 9/14/26 3:31 PM, Sean Whitton wrote:
> Steps to reproduce:
>
> git init foo
> cd foo
> mkdir bar
> echo bar/ >.gitignore
> git init bar/baz
> git init bar/quux
> git status --porcelain --ignored --untracked-files -- ba
>
> Expected output:
> none, "ba" doesn't match "bar".
>
> Actual output:
> !! bar/baz/
> !! bar/quux/
>
> Credits to Lester Longley for the reproduction, in Emacs bug#81625.
>
Bisects to 95c11ecc73 (Fix error-prone fill_directory() API; make it
only return matches, 2020-04-01).
I can reproduce the issue using the instructions above, but not in Git's
own repo like this:
$ git status --porcelain --ignored --untracked-files -- .depend | grep -c '^!!'
266
$ git status --porcelain --ignored --untracked-files -- .depen | grep -c '^!!'
0
Below is a quick fix, but perhaps this optimization can be repaired
instead of removed.
René
diff --git a/dir.c b/dir.c
index 95d8a1cce9..3718301a89 100644
--- a/dir.c
+++ b/dir.c
@@ -1991,11 +1991,9 @@ static enum path_treatment treat_directory(struct dir_struct *dir,
/*
* We don't want to descend into paths that don't match the necessary
* patterns. Clearly, if we don't have a pathspec, then we can't check
- * for matching patterns. Also, if (excluded) then we know we matched
- * the exclusion patterns so as an optimization we can skip checking
* for matching patterns.
*/
- if (pathspec && !excluded) {
+ if (pathspec) {
matches_how = match_pathspec_with_flags(istate, pathspec,
dirname, len,
0 /* prefix */,
next prev parent reply other threads:[~2026-09-15 15:54 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-14 13:31 [BUG] 'git status --ignored' <pathspec> matches partial names Sean Whitton
2026-09-15 15:54 ` René Scharfe [this message]
2026-09-18 11:04 ` [PATCH] dir: skip excluded directory with nested repo on prefix match René Scharfe
2026-09-22 4:57 ` Junio C Hamano
2026-09-26 10:51 ` René Scharfe
2026-09-26 10:48 ` [PATCH v2] " René Scharfe
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=ff9404bc-63e1-43bc-8419-9685f0bfa32d@web.de \
--to=l.s.r@web.de \
--cc=81625@debbugs.gnu.org \
--cc=git@vger.kernel.org \
--cc=lester@ieee.org \
--cc=newren@gmail.com \
--cc=spwhitton@spwhitton.name \
/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