Thread (6 messages) 6 messages, 3 authors, 13d ago

Re: [BUG] 'git status --ignored' <pathspec> matches partial names

flat view

From: René Scharfe <hidden>
Date: 2026-09-15 15:54:57
Subsystem: the rest · Maintainer: Linus Torvalds

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 */,
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help