Patterns would need to be read from:
.gitignore file in the same directory as the path, or in any parent directory (the latter allows tools to put a .gitignore file with * in the directory they create to auto-exclude themselves)
- patterns read from
$GIT_DIR/info/exclude (allows user-specific patterns for a specific repository)
- patterns read from the file specified by Git's configuration variable
core.excludesFile (allows global user-specific patterns, I personally use this one)
Reference: https://git-scm.com/docs/gitignore
This might come at a performance cost but it definitely would be a useful feature.