summaryrefslogtreecommitdiffstats
path: root/ignore/src/gitignore.rs
AgeCommit message (Collapse)Author
2018-07-29ignore: fix typoAndrew Gallant
2018-07-29ignore: fix bug in matched_path_or_any_parentsAndrew Gallant
This method was supposed to panic whenever the given path wasn't under the root of the gitignore patcher. Instead of using assert!, it was using debug_assert!. This actually caused tests to fail when running under release mode, because the debug_assert! wouldn't trip. Fixes #671
2018-07-28ignore: respect XDG_CONFIG_DIR/git/configAndrew Gallant
This commit updates the logic for finding the value of git's `core.excludesFile` configuration parameter. Namely, we now check `$XDG_CONFIG_DIR/git/config` in addition to `$HOME/.gitconfig` (where the latter overrules the former on a knob-by-knob basis). Fixes #995
2018-07-16ignore: permit use of env::home_dirAndrew Gallant
Upstream deprecated env::home_dir because of minor bugs in some corner cases. We should probably eventually migrate to a correct implementation in the `dirs` crate, but using the buggy version is just fine for now.
2018-05-06ignore/doc: improve docs for case_insensitiveGarrett Squire
This commit updates the OverrideBuilder and GitignoreBuilder docs for the case_insensitive method, denoting that it must be called before adding any patterns.
2018-04-24ignore: speed up Gitignore::emptyAndrew Gallant
This commit makes Gitignore::empty a bit faster by avoiding allocation and manually specializing the implementation instead of routing it through the GitignoreBuilder. This helps improve uses of ripgrep that traverse *many* directories, and in particular, when the use of ignores is disabled via command line switches. Fixes #835, Closes #836
2018-04-05ignore: add Clone/Debug for buildersFlorentBecker
2018-03-10ignore: support backslash escapingBrian Malehorn
Use the new `Globset::backslash_escape` knob to conform to git behavior: `\` will escape the following character. For example, the pattern `\*` will match a file literally named `*`. Also tweak a test in ripgrep that was relying on this incorrect behavior. Closes #526, Closes #811
2018-02-14ignore: fix improper hidden filteringAndrew Gallant
This commit fixes a bug where `rg --hidden .` would behave differently with respect to ignore filtering than `rg --hidden ./`. In particular, this was due to a bug where the directory name `.` caused the leading `.` in a hidden directory to get stripped, which in turn caused the ignore rules to fail. Fixes #807
2018-01-29ignore: fix handling of / in patternsdana
This commit makes handling of patterns containing a `/` match actual git behaviour and the specification written in `man gitignore`. Fixes #761
2018-01-01cleanup: replace try! with ?Balaji Sivaraman
2017-11-01Properly match the rules "**/" and "!**/"Brian Campbell
When processing a rule that ends in a slash, we strip it off and set the `is_only_dir` flag. We then apply the rule that paths that aren't absolute should be given an implicit `**/` prefix, while avoiding adding that prefix if it already exists. However, this means that we miss the case in which we had already stripped off the trailing slash and set `is_only_dir`. Correct this by also explicitly checking for that case. Fixes #649
2017-07-13[ignore] Fix matched_path_or_any_parents() for patterns ending in slashBehnam Esfahbod
In `matched_path_or_any_parents()` implementation, we missed the point that when we start walking up the tree, we have to set `is_dir` to `true`, so path `ROOT/a/b/c` matches pattern `/a/`, although the original path is not a dir.
2017-07-12[ignore] Add extensive test for gitignore matching (#551)Behnam Esfahbod ✅
[ignore] tests and new matched_path_or_any_parents method The test data (gitignore rules and expected result) is based on the test repo at <https://github.com/behnam/gitignore-test>. The new `matched_path_or_any_parents` method fixes a bug in gitignore matching where rules of form `<dir>/*` result in ignoring only first-level files, but no deep files. This is not correct, as `<dir>/*` matches the first-level directories under `<dir>`, resulting all to be ignored. The new method fixes it by trying to match all parents in the path against the gitignore rules. The new method is necessary because it necessarily entails a performance hit for trying to match all parents.
2017-07-03add --iglob flagPeter S Panov
Working with Chris Stadler, implemented https://github.com/BurntSushi/ripgrep/issues/163#issuecomment-300012592
2017-04-12Add better error messages for invalid globs.Andrew Gallant
This threads the original glob given by end users through all of the glob parsing errors. This was slightly trickier than it might appear because the gitignore implementation actually modifies the glob before compiling it. So in order to get better glob error messages everywhere, we need to track the original glob both in the glob parser and in the higher-level abstractions in the `ignore` crate. Fixes #444
2017-03-12Fix leading slash bug when used with `!`.Andrew Gallant
When writing paths like `!/foo` in gitignore files (or when using the -g/--glob flag), the presence of `!` would prevent the gitignore builder from noticing the leading slash, which causes absolute path matching to fail. Fixes #405
2017-01-30Look for global git/ignore in ~/.config/git, not ~/gitDaniel Hahler
The documentation says: > If `$XDG_CONFIG_HOME` is not set or is empty, then > `$HOME/.config/git/ignore` is used instead. This is the expected behavior, but the code looked at ~/git/ignore instead.
2016-11-17Use env::home_dir() instead of env::var_os(HOME).Andrew Gallant
Thanks @steveklabnik!
2016-11-09Fix a bug with handling --ignore-file.Andrew Gallant
Namely, passing a directory to --ignore-file caused ripgrep to allocate memory without bound. The issue was that I got a bit overzealous with partial error reporting. Namely, when processing a gitignore file, we should try to use every pattern even if some patterns are invalid globs (e.g., a**b). In the process, I applied the same logic to I/O errors. In this case, it manifest by attempting to read lines from a directory, which appears to yield Results forever, where each Result is an error of the form "you can't read from a directory silly." Since I treated it as a partial error, ripgrep was just spinning and accruing each error in memory, which caused the OOM killer to kick in. Fixes #228
2016-10-29Move all gitignore matching to separate crate.Andrew Gallant
This PR introduces a new sub-crate, `ignore`, which primarily provides a fast recursive directory iterator that respects ignore files like gitignore and other configurable filtering rules based on globs or even file types. This results in a substantial source of complexity moved out of ripgrep's core and into a reusable component that others can now (hopefully) benefit from. While much of the ignore code carried over from ripgrep's core, a substantial portion of it was rewritten with the following goals in mind: 1. Reuse matchers built from gitignore files across directory iteration. 2. Design the matcher data structure to be amenable for parallelizing directory iteration. (Indeed, writing the parallel iterator is the next step.) Fixes #9, #44, #45