-
Notifications
You must be signed in to change notification settings - Fork 43
Closed
Description
It appears that pathspec is not handling exclusions correctly for directories without a trailing slash:
import pathspec
gitignore = """\
build
!/foo/build
"""
spec = pathspec.PathSpec.from_lines("gitwildmatch", gitignore.splitlines())
# incorrectly returns True
print(spec.match_file("foo/build/file.py"))
gitignore = """\
build
!/foo/build/
"""
spec = pathspec.PathSpec.from_lines("gitwildmatch", gitignore.splitlines())
# correctly returns False
print(spec.match_file("foo/build/file.py"))
If you try doing the same with .gitignore, it works correctly:
git init repro
cd repro
echo $'build\n!/foo/build' > .gitignore
mkdir build
touch build/file.py
mkdir -p foo/build
touch foo/build/file.py
Running git status
gives:
On branch main
No commits yet
Untracked files:
(use "git add <file>..." to include in what will be committed)
.gitignore
foo/
nothing added to commit but untracked files present (use "git add" to track)
And running git ls-files --others --exclude-standard
gives:
.gitignore
foo/build/file.py
Metadata
Metadata
Assignees
Labels
No labels