summaryrefslogtreecommitdiffstats
path: root/globset
AgeCommit message (Collapse)Author
2018-03-10globset: make ErrorKind enum extensibleAndrew Gallant
This commit makes the ErrorKind enum extensible by adding a __Nonexhaustive variant. Callers should use this as a hint that exhaustive case analysis isn't possible in a stable way since new variants may be added in the future without a semver bump.
2018-03-10globset: support backslash escapingBrian Malehorn
From `man 7 glob`: One can remove the special meaning of '?', '*' and '[' by preceding them by a backslash, or, in case this is part of a shell command line, enclosing them in quotes. Conform to glob / fnmatch / git implementations by making `\` escape the following character - for example `\?` will match a literal `?`. However, only enable this by default on Unix platforms. Windows builds will continue to use `\` as a path separator, but can still get the new behavior by calling `globset.backslash_escape(true)`. Adding tests for the `Globset::backslash_escape` option was a bit involved, since the default value of this option is platform-dependent. Extend the options framework to hold an `Option<T>` for each knob, where `None` means "default" and `Some(v)` means "override with `v`". This way we only have to specify the default values once in `GlobOptions::default()` rather than replicated in both code and tests. Finally write a few behavioral tests, and some tests to confirm it varies by platform.
2018-02-11globset: release 0.3.0globset-0.3.0Andrew Gallant
2018-02-10globset: remove use of unsafeAndrew Gallant
This commit removes, in retrospect, a silly use of `unsafe`. In particular, to extract a file name extension (distinct from how `std` implements it), we were transmuting an OsStr to its underlying WTF-8 byte representation and then searching that. This required `unsafe` and relied on an undocumented std API, so it was a bad choice to make, but everything gets sacrificed at the Alter of Performance. The thing I didn't seem to realize at the time was that: 1. On Unix, you can already get the raw byte representation in a manner that has zero cost. 2. On Windows, paths are already being encoded and copied every which way. So doing a UTF-8 check and, in rare cases (for invalid UTF-8), an extra copy, doesn't seem like that much more of an added expense. Thus, rewrite the extension extraction using safe APIs. On Unix, this should have identical performance characteristics as the previous implementation. On Windows, we do pay a higher cost in the UTF-8 check, but Windows is already paying a similar cost a few times over anyway.
2018-02-06globset: add more tests for single-asterisk patternBehnam Esfahbod
This adds a few tests that check for bugs reported here: https://github.com/rust-lang/cargo/issues/4268 The bugs reported in the aforementioned issue are probably caused by not enabling the `literal_separator` option in `GlobBuilder`. Enabling that in the tests under question fixes the issue. Closes #773
2018-02-04logger: drop env_loggerAndrew Gallant
This commit updates the `log` crate to 0.4 and drops the dependency on env_logger. In particular, the latest version of env_logger brings in additional non-optional dependencies such as chrono that I don't think is worth including into ripgrep. It turns out ripgrep doesn't need any fancy logging. We just need a concept of log levels and the ability to print to stderr. Therefore, we just roll our own super simple logger. This update is motivated by the persistent configuration task. In particular, we need the ability to toggle the global log level more than once, and this doesn't appear to be possible with older versions of the log crate.
2018-01-01cleanup: replace try! with ?Balaji Sivaraman
2017-11-22Support both [^...] and [!...] for globset class negationdana
Adds support for [^...] class negation in globs for parity with git, &al. Fixes #663
2017-11-01fix some typosMartin Lindhe
2017-10-21cargo: bump to 0.7.0ignore-0.3.0grep-0.1.7globset-0.2.10.7.0Andrew Gallant
2017-10-21deps: upgrade to memchr 2Andrew Gallant
2017-10-08globset README version bumpBenjamin Sago
2017-05-11bump ripgrep, ignore, globset0.5.2Andrew Gallant
The `ignore` and `globset` crates both got breaking changes in the course of fixing #444, so increase 0.x to 0.(x+1).
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-12Bump and update deps.wincolor-0.1.3termcolor-0.3.1ignore-0.1.8grep-0.1.6globset-0.1.4Andrew Gallant
2017-03-12Add license files to each crate.Andrew Gallant
Fixes #381
2017-03-08Add enclosing group to alternations in globsMarc Tiehuis
Fixes #391.
2017-02-18Implement Hash for Glob, and re-implement PartialEq using only non-redundant ↵Stu Hood
fields.
2017-02-12Remove lazy_static from globsetAndrew Gallant
2017-01-130.4.00.4.0Andrew Gallant
2017-01-03bump depsAndrew Gallant
2017-01-01Update to regex 0.2.Andrew Gallant
2016-12-30bump various versionsAndrew Gallant
2016-12-12Fix cut-off line in globset docs.Andrew Gallant
Fixes #277
2016-11-06globset-0.1.2globset-0.1.2Andrew Gallant
2016-11-06Add --no-messages flag.Andrew Gallant
This flag is similar to what's found in grep: it will suppress all error messages, such as those shown when a particular file couldn't be read. Closes #149
2016-10-29globset-0.1.1globset-0.1.1Andrew Gallant
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
2016-10-10globset-0.1.0globset-0.1.0Andrew Gallant
2016-10-10add version markerAndrew Gallant
2016-10-10Fill in globset/Cargo.toml with more details.Andrew Gallant
2016-10-10Finish overhaul of glob matching.Andrew Gallant
This commit completes the initial move of glob matching to an external crate, including fixing up cross platform support, polishing the external crate for others to use and fixing a number of bugs in the process. Fixes #87, #127, #131
2016-10-04Refactor and test glob sets.Andrew Gallant
This commit goes a long way toward refactoring glob sets so that the code is easier to maintain going forward. In particular, it makes the literal optimizations that glob sets used a lot more structured and much easier to extend. Tests have also been modified to include glob sets. There's still a bit of polish work left to do before a release. This also fixes the immediate issue where large gitignore files were causing ripgrep to slow way down. While we don't technically fix it for good, we're a lot better about reducing the number of regexes we compile. In particular, if a gitignore file contains thousands of patterns that can't be matched more simply using literals, then ripgrep will slow down again. We could fix this for good by avoiding RegexSet if the number of regexes grows too large. Fixes #134.
2016-09-30Move glob implementation to new crate.Andrew Gallant
It is isolated and complex enough that it deserves attention all on its own. It's also eminently reusable.