You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Dir-only pattern with a wildcard: the directory matches, nothing inside it does #23
A dir-only pattern whose last segment has a wildcard and ends in literal text matches the directory,
but nothing inside it:
.gitignore: *.egg-info/
mypkg.egg-info/ git: ignored this library: ignored
mypkg.egg-info/PKG-INFO git: ignored this library: NOT ignored <--
mypkg.egg-info/sub/x.txt git: ignored this library: NOT ignored <--
build/ is fine, and so is *.egg-info without the trailing slash. What breaks it is the
fast-reject in match (gitignore.go:359, and the same line in matchDetail:376):
lastSeg is the last segment of the queried path. That is a sound test when the pattern is
compared against the whole path, but a dir-only pattern can match an ancestor — PKG-INFO
doesn't end in .egg-info and never will, so the pattern is dropped before matchPattern gets to
its descendant loop. Adding && !p.dirOnly to both lines fixes it; go test ./..., gofmt -l and go vet stay clean, and it moves nothing on my conformance bench (4,463 nested-.gitignore
queries against git check-ignore, 5 divergences before and after — 3 of those 5 are #22, the
other 2 are unrelated).
Prevalence, since the shape sounds exotic and isn't: taking the rule files of 33 large repos as
written, 9 distinct lines hit this — *.egg-info/ in airflow, transformers, langchain, vscode,
flask and pytorch, *.framework/ in tensorflow, testdata/**output/ in grafana. [Bb]uild/ has
the same shape and does not fail, which is why I measured each line instead of counting the form.
My bench missed it, for the record: it never asks about a file inside one of those directories.
Activity
Don't fast-reject a dir-only pattern by the queried path's last segment