svent / sift

A fast and powerful alternative to grep
https://sift-tool.org
GNU General Public License v3.0
1.6k stars 108 forks source link

Support all gitignore pattern sources #77

Open Deewiant opened 8 years ago

Deewiant commented 8 years ago

From git help ignore:

When deciding whether to ignore a path, Git normally checks gitignore patterns from multiple sources, with the following order of precedence, from highest to lowest (within one level of precedence, the last matching pattern decides the outcome):

  • Patterns read from the command line for those commands that support them.
  • Patterns read from a .gitignore file in the same directory as the path, or in any parent directory, with patterns in the higher level files (up to the toplevel of the work tree) being overridden by those in lower level files down to the directory containing the file. These patterns match relative to the location of the .gitignore file. A project normally includes such .gitignore files in its repository, containing patterns for files generated as part of the project build.
  • Patterns read from $GIT_DIR/info/exclude.
  • Patterns read from the file specified by the configuration variable core.excludesFile.

(The text continues by explaining why these latter three alternatives exist.)

As far as I can tell sift currently does not take into account $GIT_DIR/info/exclude nor the file specified in core.excludesFile.

svent commented 8 years ago

Thanks for your suggestion. I focused on a correct support of the various possible .gitignore patterns for the initial implementation, as I think that is most important for the majority of users and many people do not use the alternative source locations.

Most tools implement support for the global gitignore file by executing git on the system to retrieve the file location - I don't want to do that (execute external programs) and I do not think this would be a great benefit. A global sift config or a .gitignore file in the root directory should work for most cases.

I will take a closer look at the $GIT_DIR/info/exclude alternative - if that does not lead to significant overhead compared to the current implementation I will add that feature.

Deewiant commented 8 years ago

Personally, I use $GIT_DIR/info/exclude a lot so I'd very much enjoy having that feature.

I haven't had any use for core.excludesFile so at least currently I don't miss it, but I thought I'd include it in the issue for completeness.

78 could be used as a workaround for a lack of $GIT_DIR/info/exclude support, if you find that one more acceptable.