diff options
author | Andrew Gallant <jamslam@gmail.com> | 2019-04-08 19:28:38 -0400 |
---|---|---|
committer | Andrew Gallant <jamslam@gmail.com> | 2019-04-14 19:29:27 -0400 |
commit | a7d26c8f144a4957b75f71087a66692d0b25759a (patch) | |
tree | 4888ac5ea66643ac919d4e12c60cc51992bef11a /CHANGELOG.md | |
parent | bd222ae93fa0cabe7d51ba8db40ece99579bdaed (diff) |
binary: rejigger ripgrep's handling of binary files
This commit attempts to surface binary filtering in a slightly more
user friendly way. Namely, before, ripgrep would silently stop
searching a file if it detected a NUL byte, even if it had previously
printed a match. This can lead to the user quite reasonably assuming
that there are no more matches, since a partial search is fairly
unintuitive. (ripgrep has this behavior by default because it really
wants to NOT search binary files at all, just like it doesn't search
gitignored or hidden files.)
With this commit, if a match has already been printed and ripgrep detects
a NUL byte, then it will print a warning message indicating that the search
stopped prematurely.
Moreover, this commit adds a new flag, --binary, which causes ripgrep to
stop filtering binary files, but in a way that still avoids dumping
binary data into terminals. That is, the --binary flag makes ripgrep
behave more like grep's default behavior.
For files explicitly specified in a search, e.g., `rg foo some-file`,
then no binary filtering is applied (just like no gitignore and no
hidden file filtering is applied). Instead, ripgrep behaves as if you
gave the --binary flag for all explicitly given files.
This was a fairly invasive change, and potentially increases the UX
complexity of ripgrep around binary files. (Before, there were two
binary modes, where as now there are three.) However, ripgrep is now a
bit louder with warning messages when binary file detection might
otherwise be hiding potential matches, so hopefully this is a net
improvement.
Finally, the `-uuu` convenience now maps to `--no-ignore --hidden
--binary`, since this is closer to the actualy intent of the
`--unrestricted` flag, i.e., to reduce ripgrep's smart filtering. As a
consequence, `rg -uuu foo` should now search roughly the same number of
bytes as `grep -r foo`, and `rg -uuua foo` should search roughly the
same number of bytes as `grep -ra foo`. (The "roughly" weasel word is
used because grep's and ripgrep's binary file detection might differ
somewhat---perhaps based on buffer sizes---which can impact exactly what
is and isn't searched.)
See the numerous tests in tests/binary.rs for intended behavior.
Fixes #306, Fixes #855
Diffstat (limited to 'CHANGELOG.md')
-rw-r--r-- | CHANGELOG.md | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index 0e9f381d..fad6dc11 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,11 @@ TODO. error (e.g., regex syntax error). One exception to this is if ripgrep is run with `-q/--quiet`. In that case, if an error occurs and a match is found, then ripgrep will exit with a `0` exit status code. +* Supplying the `-u/--unrestricted` flag three times is now equivalent to + supplying `--no-ignore --hidden --binary`. Previously, `-uuu` was equivalent + to `--no-ignore --hidden --text`. The difference is that `--binary` disables + binary file filtering without potentially dumping binary data into your + terminal. That is, `rg -uuu foo` should now be equivalent to `grep -r foo`. * The `avx-accel` feature of ripgrep has been removed since it is no longer necessary. All uses of AVX in ripgrep are now enabled automatically via runtime CPU feature detection. The `simd-accel` feature does remain @@ -25,6 +30,8 @@ Performance improvements: Feature enhancements: +* [FEATURE #855](https://github.com/BurntSushi/ripgrep/issues/855): + Add `--binary` flag for disabling binary file filtering. * [FEATURE #1099](https://github.com/BurntSushi/ripgrep/pull/1099): Add support for Brotli and Zstd to the `-z/--search-zip` flag. * [FEATURE #1138](https://github.com/BurntSushi/ripgrep/pull/1138): @@ -36,6 +43,9 @@ Feature enhancements: Bug fixes: +* [BUG #306](https://github.com/BurntSushi/ripgrep/issues/306), + [BUG #855](https://github.com/BurntSushi/ripgrep/issues/855): + Improve the user experience for ripgrep's binary file filtering. * [BUG #373](https://github.com/BurntSushi/ripgrep/issues/373), [BUG #1098](https://github.com/BurntSushi/ripgrep/issues/1098): `**` is now accepted as valid syntax anywhere in a glob. |