Problem
Currently the user is required to find and read any gitignore files to use. This means that they have to understand how git uses those files. In addition, where to provide the root dir and how it is used is confusing. #126
Request
Add support to GitIgnoreSpec
- require specifing the root directory it should use when applying patterns
- have it read the Git ignore files using the git algorithm
- read the global ignore file
- read the project .gitignore
- read any .gitignore files in project subdirectories
This would make using GitIgnoreSpec easier and remove some of the problems current users encounter trying to use the interface.
Details
(I am ignoring any non-git pathspecs in this request.)
Currently when constructing a PathSpec, the user must provide the ignore patterns, and the root directory is not provided at the same time which means the GitIgnoreSpec does not know what directory the patterns are relative to.
It would be helpful if when constructing a GitIgnoreSpec, or other git variants, that the API would require the (project) root directory. This is the directory container .git/
When git runs it looks in the current directory for .gitignore and if not found looks up the parent tree. This allows it to run in a project subdirectory and still find the .gitignore in the directory containing .git/
Git also uses user/global ignores if defined
Example:
Given the following directory tree (with the .git/ directory omitted)
and the content of ignore files
$ cat ~/.config/git/ignore
# these should always be excluded in any repository
tmp*
*tmp
.tmp*
*.swp
$ cat .gitignore
fred
$ cat src/module1/.gitignore
bob
the following is the output of using git check-ignore (with .git/* removed)
$ find . | git check-ignore -vn --stdin
:: .
:: ./.gitignore
:: ./src
:: ./src/module1
:: ./src/module1/.gitignore
src/module1/.gitignore:1:bob ./src/module1/bob
.gitignore:1:fred ./src/module1/fred
:: ./src/module1/bill
/home/julie/.config/git/ignore:3:*tmp ./src/todo.tmp
:: ./bob
.gitignore:1:fred ./fred
/home/julie/.config/git/ignore:3:*tmp ./tmp
so you can see how git applies the content of the different ignore files.
Problem
Currently the user is required to find and read any gitignore files to use. This means that they have to understand how git uses those files. In addition, where to provide the root dir and how it is used is confusing. #126
Request
Add support to GitIgnoreSpec
This would make using GitIgnoreSpec easier and remove some of the problems current users encounter trying to use the interface.
Details
(I am ignoring any non-git pathspecs in this request.)
Currently when constructing a PathSpec, the user must provide the ignore patterns, and the root directory is not provided at the same time which means the GitIgnoreSpec does not know what directory the patterns are relative to.
It would be helpful if when constructing a GitIgnoreSpec, or other git variants, that the API would require the (project) root directory. This is the directory container .git/
When git runs it looks in the current directory for .gitignore and if not found looks up the parent tree. This allows it to run in a project subdirectory and still find the .gitignore in the directory containing .git/
Git also uses user/global ignores if defined
Example:
Given the following directory tree (with the .git/ directory omitted)
and the content of ignore files
the following is the output of using git check-ignore (with .git/* removed)
so you can see how git applies the content of the different ignore files.