summaryrefslogtreecommitdiffstats
AgeCommit message (Collapse)Author
2020-02-17ignore: use git commondir for sourcing .git/info/excludeJohannes Altmanninger
Git looks for this file in GIT_COMMON_DIR, which is usually the same as GIT_DIR (.git). However, when searching inside a linked worktree, .git is usually a file that contains the path of the actual git dir, which in turn contains a file "commondir" which references the directory where info/exclude may reside, alongside other configuration shared across all worktrees. This directory is usually the git dir of the main worktree. Unlike git this does *not* read environment variables GIT_DIR and GIT_COMMON_DIR, because it is not clear how to interpret them when searching multiple repositories. Fixes #1445, Closes #1446
2020-02-17cli: make ripgrep work in non-existent directoriesAndrew Gallant
It turns out that querying the CWD while in a directory that no longer exists results in an error. Since the CWD is queried every time ripgrep starts---whether it needs it or not---for dealing with glob matching, ripgrep winds up being completely useless inside a non-existent directory. We fix this in a few different ways: * Firstly, if std::env::current_dir() fails, then we fall back to trying to read the `PWD` environment variable. * If that fails, that we return a more sensible error message so that a user can at least react to the problem. Previously, the error message was inscrutable. * Finally, we try to avoid the problem altogether by building empty glob matchers if not globs were provided, thus side-stepping querying the CWD completely. Fixes #1291, Closes #1400
2020-02-17cli: add --no-ignore-exclude flagNaveen Nathan
This commit adds a new --no-ignore-exclude flag that permits disabling the use of .git/info/exclude filtering. Local exclusions are manual configurations to a repository and are not shared, so it is sometimes useful to disable to get a consistent view of a repository. This also adds a new section to the man page that describes automatic filtering. Closes #1420
2020-02-17globset: implement FromStr for GlobManfred Endres
The `globset::Glob` type [`new`] function creates a new value with an `&str` parameter which returns an `Result<Glob, Error>` object. This is exactly what [`std::str::FromStr::from_str`][`std::str::FromStr`] defines. Libraries like [`clap`] use [`std::str::FromStr`] to create objects from provided commandline arguments. This change makes this library usable without a newtype wrapper. [`std::str::FromStr`]: https://doc.rust-lang.org/std/str/trait.FromStr.html [`clap`]: https://docs.rs/clap/2.33.0/clap/macro.value_t.html [`new`]: https://docs.rs/globset/0.4.4/globset/struct.Glob.html#method.new Closes #1447
2020-02-17globset: add GlobMatcher::globLucien Greathouse
This exposes the underlying `Glob` used to compile the matcher. This can be useful for wrapping up the glob matcher in other types. Closes #1454
2020-02-17grep-regex: add fast path for -w/--word-regexpAndrew Gallant
Previously, ripgrep would always defer to the regex engine's capturing matches in order to implement word matching. Namely, ripgrep would determine the correct match offsets via a capturing group, since the word regex is itself generated from the user supplied regex. Unfortunately, the regex engine's capturing mode is still fairly slow, so this commit adds a fast path to avoid capturing mode in the vast majority of cases. See comments in the code for details.
2020-02-17grep-regex: improve literal detection with -wAndrew Gallant
When the -w/--word-regexp was used, ripgrep would in many cases fail to apply literal optimizations. This occurs specifically when the regex given by the user is an alternation of literals with no common prefixes or suffixes, e.g., rg -w 'foo|bar|baz|quux' In this case, the inner literal detector fails. Normally, this would result in literal prefixes being detected by the regex engine. But because of the -w/--word-regexp flag, the actual regex that we run ends up looking like this: (^|\W)(foo|bar|baz|quux)($|\W) which of course defeats any prefix or suffix literal optimizations in the regex crate's somewhat naive extractor. (A better extractor could still do literal optimizations in the above case.) So this commit fixes this by falling back to prefix or suffix literals when they're available instead of prematurely giving up and assuming the regex engine will do the rest.
2020-02-17grep-regex: improve inner literal detectionAndrew Gallant
This fixes an interesting performance bug where the inner literal extractor would sometimes choose a sub-optimal literal. For example, consider the regex: \x20+Sherlock Holmes\x20+ (The `\x20` is the ASCII code for a space character, which we use here to just make it clearer. It otherwise does not matter.) Previously, this would see the initial \x20 and then stop collecting literals after the `+` repetition operator. This was because the inner literal detector was adapter from the prefix literal detector, which had to stop here. Namely, while \x20S would be a valid prefix (for example), \x20\x20S would also be a valid prefix. As would \x20\x20\x20S and so on. So the prefix detector would have to stop at the repetition operator. Otherwise, only searching for \x20S could potentially scan farther then the starting position of the next match. However, for inner literals, this calculus no longer makes sense. We can freely search for, e.g., \x20S without missing matches that start with \x20\x20S precisely because we know this is an inner literal which may not correspond to the start of a match. With this fix, the literal that is now detected is \x20Sherlock Holmes\x20 Which is much better. We achieve this by no longer "cutting" literals after seeing a `+` repetition operator. Instead, we permit literals to continue to be extended. The reason why this is important is because using \x20 as the literal to search for is generally bad juju since it is so common. In fact, we should probably add more logic here to either avoid such things or give up entirely on the inner literal optimization if it detected a literal that we think is very common. But we punt on such things here.
2020-02-17doc: document `all` file typeRobert Irelan
This adds it to the guide and the docs for the --type flag. Fixes #1344, Closes #1472
2020-02-17doc: improve docs for `--sort` and `--sortr` flagsMikko Vedru
I improved the help documentation in the following manner and for the following reasons: 1. It's only logical to put the default sub-option on the first possible line, as well as to separately mention that it is indeed the default sub-option. 2. Additional options for the flags should describe the main points of their purpose without requiring user to read the whole help entry. In my opinion, the information sub-options' influence on multi-threading and speed are important enough to warrant their inclusion in each sub-option's description line text. Closes #1434
2020-02-17readme: simplify openSUSE instructionsAndreas Stieger
Closes #1436
2020-02-17cli: add --include-zero flagCollin Styles
This flag, when used in conjunction with --count or --count-matches, will print a result for each file searched even if there were zero matches in that file. This is off by default but can be enabled to make ripgrep behave more like grep. This also clarifies some of the defaults for the grep-printer::SummaryBuilder type. Closes #1370, Closes #1405
2020-02-17ignore/types: add spec file typeMatěj Cepl
This is for RPM package SPEC files. Fixes #946, Closes #1449
2020-02-17explicitly declare lazy_static dependencyXimin Luo
`benches/bench.rs` uses lazy_static but Cargo.toml does not declare a dependency on it. This causes rustc to use its own internal private copy instead. Sometimes this causes unintuitive errors like this Debian bug: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=942243 The underlying issue is https://github.com/rust-lang/rust#27812 but it can be avoided by explicitly declaring the dependency, which you are supposed to do anyways. Closes #1435
2020-02-17ignore/types: add xhtml to xml file typeluh2
Closes #1426
2020-02-17changelog: add notes about new file typesAndrew Gallant
2020-02-17ignore/types: add 'diff' file typeSven-Hendrik Haase
This includes .patch and .diff files. Fixes #1418, Closes #1419
2020-02-17cli: add --no-context-separator flagMohammad AlSaleh
--context-separator='' still adds a new line separator, which could still potentially be useful. So we add a new `--no-context-separator` flag that completely disables context separators even when the -A/-B/-C context flags are used. Closes #1390
2020-02-17tests: remove existing test directoryAndrew Gallant
I'm surprised this wasn't caught until now, but if a test directory already exists, then it was reused. This can result in hard to debug problems with tests when, e.g., file names are changed and a recursive search is executed.
2020-02-17ignore: add existence check for ignore filessharkdp
This commit adds a simple `.exists()` check for `.gitignore`, `.ignore`, and other similar files before actually calling `File::open(…)` in `GitIgnoreBuilder::add`. The reason is that a simple existence check via `stat` can be faster than actually trying to `open` the file, see https://stackoverflow.com/a/12774387/704831. As we typically expect(?) the number of directories *without* ignore files to be much larger than the number of directories *with* ignore files, this leads to an overall speedup. The performance gain is not huge for `rg`, but can be quite significant if more `.gitignore`-like files are added via `add_custom_ignore_filename`. The speedup is *larger* for folders with *low* files-per-directory ratios. Note though that we do not do this check on Windows until a specific analysis there suggests this is beneficial. Namely, Windows generally has slower file system operations, so it's not clear whether this speculative check is actually a benefit or not. Benchmark results ----------------- `rg --files` in my home folder (200k results, 6.5 files per directory): | Command | Mean [ms] | Min [ms] | Max [ms] | Relative | |:---|---:|---:|---:|---:| | `./rg-master --files` | 396.4 ± 3.2 | 390.9 | 400.0 | 1.05 | | `./rg-feature --files` | 376.0 ± 3.6 | 369.3 | 383.5 | 1.00 | `rg --files --hidden` in my home folder (800k results, 5.4 files per directory) | Command | Mean [s] | Min [s] | Max [s] | Relative | |:---|---:|---:|---:|---:| | `./rg-master --files --hidden` | 1.575 ± 0.012 | 1.560 | 1.597 | 1.06 | | `./rg-feature --files --hidden` | 1.479 ± 0.011 | 1.464 | 1.496 | 1.00 | `rg --files` in the chromium-79.0.3915.2 source tree (300k results, 12.7 files per directory) | Command | Mean [ms] | Min [ms] | Max [ms] | Relative | |:---|---:|---:|---:|---:| | `~/rg-master --files` | 445.2 ± 5.3 | 435.6 | 453.0 | 1.04 | | `~/rg-feature --files` | 428.9 ± 7.0 | 418.2 | 440.0 | 1.00 | `rg --files` in the linux-5.3 source tree (65k results, 15.1 files per directory) | Command | Mean [ms] | Min [ms] | Max [ms] | Relative | |:---|---:|---:|---:|---:| | `./rg-master --files` | 94.5 ± 1.9 | 89.8 | 98.5 | 1.02 | | `./rg-feature --files` | 92.6 ± 2.7 | 88.4 | 98.7 | 1.00 | Closes #1381
2020-02-15readme: remove outdated SIMD infoGibson Fahnestock
Looks like the upstream brew Formula [0][] now has SIMD support, so remove the extraneous info now that the custom tap is no longer needed [1][]. [0]: https://github.com/Homebrew/homebrew-core/blob/master/Formula/ripgrep.rb [1]: https://github.com/BurntSushi/ripgrep/commit/f3083e4574ad20881de66fdeb66d671f1cbdfda4 PR #1431
2020-02-15readme: document CentOS 8 supportSorin Sbarnea
ripgrep install instructions are valid even for the 7 version. The tool works without problems on these too. PR #1428
2020-02-15ignore/types: add HAML and ERBJonathan Mast
These are commonly used templating languages for Ruby, add their extensions to the filetypes list for convenient filtering. PR #1407
2020-02-15ignore/types: add slim, slime, and skim templatesJeff S
PR #1391
2020-02-10ignore: allow use of Error::descriptionAndrew Gallant
We can remove it in the next semver incompatible release.
2020-02-07ignore/types: add typoscript file typeLuca Kredel
Add the file types for TypoScript - the configuration language of the TYPO3 CMS. PR #1477
2020-02-05faq: add section about donationsAndrew Gallant
This is asked often enough that it's worth having a canonical answer.
2020-01-30deps: update everythingAndrew Gallant
2020-01-30deps: update regex, regex-syntax and aho-corasickAndrew Gallant
Notably, this brings in a bug fix reported by @okdana: https://github.com/rust-lang/regex/issues/640
2020-01-29ignore/types: add *.org_archive to org file typeRobert Irelan
.org_archive is the default extension for Org archive files, created when entries from an Org-mode file are archived (see <https://orgmode.org/org.html#Moving-subtrees>). These files are still in Org mode format, so it's worth searching them at the same time as non-archive Org mode files. PR #1475
2020-01-27globset: fix benchmarksAndrew Gallant
There were apparently a lot of unused things, including lazy_static.
2020-01-23ignore/types: make 'gradle' it's own typeTristan Waddington
This change maintains the existing behavior of the 'groovy' type, which includes both .groovy and .gradle files. PR #1470
2020-01-21readme: add instructions for Haiku x86_64 and x86_gcc2Crestwave
PR #1465
2020-01-21readme: update outdated linksAlex Touchet
PR #1463
2020-01-20doc: add missing "will" to the user guideOliver Newman
PR #1462
2020-01-20ignore/types: fix postscript globsJan Verbeek
The postscript globs were missing asterisks, so they were treated as literal filenames. PR #1461
2020-01-16deps: update everythingAndrew Gallant
2020-01-11deps: various updatesAndrew Gallant
Most of these updates (sans thread_local) are from crates I maintain that have seen updates recently. Notably, this includes a bump to `termcolor 1.1.0` which includes support for respecting `NO_COLOR`. This commit therefore means that ripgrep now supports `NO_COLOR`. As an added bonus, we drop a dependency on Windows. (Although the total amount of code compiled remains the same.) Closes #1186
2020-01-10ignore-0.4.11ignore-0.4.11Andrew Gallant
2020-01-10ci: fix musl docker buildAndrew Gallant
Looks like the old japaric images are bunk. We update our docker image to be based on the new rustembedded images and configure cross to use it. Turns out that this wasn't due to a stale docker image, but rather, a bug in cross: https://github.com/rust-embedded/cross/issues/357 We work around that bug by installing the master branch of cross. Sigh.
2020-01-10ci: disable github actions for nowAndrew Gallant
The CI build failures are annoying and distracting. Hopefully soon I'll be able to invest more time in the switch.
2020-01-10deps: update to crossbeam-channel 0.4Andrew Gallant
Closes #1427
2020-01-10deps: update to bytecount 0.6Andrew Gallant
Looks like there aren't any major changes other than dependency updates.
2020-01-10deps: update to thread_local 1.0Andrew Gallant
We also update the pcre2 and regex dependencies, which removes any other lingering uses of thread_local 0.3.
2020-01-10deps: bump to base64 0.11Andrew Gallant
2020-01-10deps: run cargo updateAndrew Gallant
The only new dependency is an unused target specific dependency hermit via the atty crate.
2019-09-25doc: fix typo in FAQYevgen Antymyrov
2019-09-11ci: get GitHub Actions running againJonathan Clem
Basically, matrix.os needs to be defined for every build. We were commenting out some of the builds in order to debug CI in the `include` section, but we also need to comment them out in the `build section.
2019-08-31ci: initial github actions configAndrew Gallant
2019-08-28ignore: remove unused parameterAndrew Gallant