1
0
mirror of https://github.com/BurntSushi/ripgrep.git synced 2024-12-12 19:18:24 +02:00
Commit Graph

563 Commits

Author SHA1 Message Date
Andrew Gallant
cffba53379 use termcolor 0.3, not 0.1 2017-02-19 11:27:41 -05:00
Andrew Gallant
79d40d0e20 Tweak how binary files are handled internally.
This commit fixes two issues. The first issue is that if a file contained
many NUL bytes without any LF bytes, then the InputBuffer would read the
entire file into memory. This is not typically a problem, but if you run
rg on /proc, then bad things can happen when reading virtual memory mapping
files. Arguably, such files should be ignored, but we should also try to
avoid exhausting memory too. We fix this by pushing the `-a/--text` flag
option down into InputBuffer, so that it knows to stop immediately if it
finds a NUL byte.

The other issue this fixes is that binary detection is now applied to every
buffer instead of just the first one. This helps avoid detecting too many
files as plain text if the first parts of a binary file happen to contain
no NUL bytes. This issue still persists somewhat in the memory map
searcher, since we probably don't want to search the entire file upfront
for NUL bytes before actually performing our search. Instead, we search the
first 10KB for now.

Fixes #52, Fixes #311
2017-02-18 16:20:21 -05:00
Andrew Gallant
525b278049 Don't parses regexes with --files.
When the --files flag is given, ripgrep would still try to parse some of
the positional arguments as regexes. Don't do that.

Fixes #326
2017-02-18 15:34:54 -05:00
Andrew Gallant
16de47920c Permit --heading to override --no-heading.
@kbknapp <3

Fixes #327
2017-02-18 15:25:08 -05:00
Andrew Gallant
a114b86063 update termcolor dep 2017-02-18 15:09:25 -05:00
Andrew Gallant
a5a16ebb27 termcolor-0.3.0 2017-02-18 15:07:43 -05:00
Andrew Gallant
8ac5bc0147 Remove Windows deps from ripgrep proper.
All Windows specific code has been (mostly) pushed out of ripgrep and
into its constituent libraries.
2017-02-18 15:06:20 -05:00
Stu Hood
cf750a190f Implement Hash for Glob, and re-implement PartialEq using only non-redundant fields. 2017-02-18 11:46:03 -05:00
Andrew Gallant
d825648b86 Remove lazy_static from globset 2017-02-12 15:37:50 -05:00
Peter Williams
22cb644eb6 termcolor: add support for output to standard error
This is essentially a rename of the existing `Stdout` type to `StandardStream`
and a change of its constructor from a single `new()` function to have two
`stdout()` and `stderr()` functions.

Under the hood, we add add internal IoStandardStream{,Lock} enums that allow
us to abstract between Stdout and Stderr conveniently. The rest of the needed
changes then fall out fairly naturally.

Fixes #324.

[breaking-change]
2017-02-09 20:57:23 -05:00
Ahmed El Gabri
e424f87487 Add .twig as a Filetype 2017-02-09 15:12:48 -05:00
Samuel Colvin
f5b2c96b77 add '*.sass' to sass type 2017-01-31 07:26:25 -05:00
Daniel Hahler
6e209b6fdb Look for global git/ignore in ~/.config/git, not ~/git
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.
2017-01-30 16:58:58 -05:00
Alexander Altman
72e3c54e0a Add Ceylon file type filtering 2017-01-24 07:16:53 -05:00
Andrew Gallant
b67886264f Add 'text-processing' category. 2017-01-21 11:31:09 -05:00
Jake Goulding
e67ab459d3 Add categories to Cargo.toml 2017-01-20 14:20:28 -05:00
David Stangl
7a926d090d Fix homebrew formula 2017-01-19 08:33:54 -05:00
Tareq A Khandaker
596f94aa7f Add shell completion files to ripgrep-bin.rb 2017-01-18 18:39:11 -05:00
robi-wan
de55d37bea File Types: Add .eex under Elixir
.eex is the default file ending for templates using Elixir's template engine EEx.
2017-01-18 18:38:53 -05:00
Andrew Gallant
fecef10c1c update deps 2017-01-17 19:36:23 -05:00
Andrew Gallant
79e5e6671f wincolor-0.1.2 2017-01-17 19:34:48 -05:00
Andrew Gallant
b04a68a782 Update 0.4.0 changelog.
It was missing a change about colors/styles.

Fixes #330
2017-01-17 19:34:18 -05:00
Peter Williams
e573ab5c60 Add stderr support to wincolor. 2017-01-17 10:42:35 -05:00
Andrew Gallant
f5a2d022ec Replace internal atty module with atty crate.
This removes all use of explicit unsafe in ripgrep proper except for
one: accessing the contents of a memory map. (Which may never go away.)
2017-01-15 16:32:30 -05:00
Andrew Gallant
b1d1cd2366 note minimum Rust version 2017-01-14 08:51:30 -05:00
Andrew Gallant
f26e0f088f update brew tap 2017-01-14 00:05:05 -05:00
Andrew Gallant
057ed6305a 0.4.0 2017-01-13 23:46:21 -05:00
Andrew Gallant
730beb9cb5 changelog 0.4.0 2017-01-13 23:40:11 -05:00
Andrew Gallant
ed60ec736c Fix invalid UTF-8 output on Windows.
Currently, Rust's standard library will yield an error if one tries to
write invalid UTF-8 to a Windows console. This is problematic for
ripgrep when it tries to print matched lines that contain invalid UTF-8.
We work around this by modifying the `termcolor` library to lossily
decode UTF-8 before sending it to `std::io::Stdout`. This may result in
some Unicode replacement chars being shown in the output, but this is
strictly better than erroring or not showing anything at all.

Fixes #318.
2017-01-13 23:21:39 -05:00
Andrew Gallant
a7ca2d6563 update same-file dep 2017-01-13 20:01:06 -05:00
Andrew Gallant
a7d0e40668 Use basic SGR sequences when possible.
In Emacs, its terminal apparently doesn't support "extended" sets of
foreground/background colors. Unless we need to set an "intense" color,
we should instead use one of the eight basic color codes.

Also, remove the "intense" setting from the default set of colors. It
doesn't do much anyway and enables the default color settings to work
in Emacs out of the box.

Fixes #182 (again)
2017-01-13 19:03:03 -05:00
Andrew Gallant
7a951f103a Make --column imply --line-number.
Closes #243
2017-01-11 18:53:35 -05:00
Andrew Gallant
c3de1f58ea another bytecount update, weird 2017-01-10 21:13:40 -05:00
Andrew Gallant
e940bc956d update bytecount
Fixes #313
2017-01-10 18:30:16 -05:00
Andrew Gallant
8751e55706 Add --path-separator flag.
This flag permits setting the path separator used for all file paths
printed by ripgrep in normal operation.

Fixes #275
2017-01-10 18:16:15 -05:00
Andrew Gallant
2143bcf9cb Add example to -r/--replace docs.
Fixes #308
2017-01-10 16:43:28 -05:00
Andrew Gallant
a6a24bafb3 fix minimum Rust version 2017-01-09 20:02:29 -05:00
Andrew Gallant
db27a33827 remove redundant words 2017-01-09 20:01:26 -05:00
Andrew Gallant
083fb73790 add anti-pitch 2017-01-09 19:55:56 -05:00
Andrew Gallant
461e0c4e33 Don't search stdout redirected file.
When running ripgrep like this:

    rg foo > output

we must be careful not to search `output` since ripgrep is actively writing
to it. Searching it can cause massive blowups where the file grows without
bound.

While this is conceptually easy to fix (check the inode of the redirection
and the inode of the file you're about to search), there are a few problems
with it.

First, inodes are a Unix thing, so we need a Windows specific solution to
this as well. To resolve this concern, I created a new crate, `same-file`,
which provides a cross platform abstraction.

Second, stat'ing every file is costly. This is not avoidable on Windows,
but on Unix, we can get the inode number directly from directory traversal.
However, this information wasn't exposed, but now it is (through both the
ignore and walkdir crates).

Fixes #286
2017-01-09 16:12:08 -05:00
chocolateboy
82df3b7685 add Kotlin type: "*.kt", "*.kts"
https://en.wikipedia.org/wiki/Kotlin_(programming_language)
https://github.com/udalov/kotlin-vim/blob/master/ftdetect/kotlin.vim
2017-01-09 16:11:47 -05:00
chocolateboy
ece6011164 Ruby type: add "Gemfile", "*.gemspec", ".irbrc", "Rakefile"
https://github.com/vim-ruby/vim-ruby/blob/master/ftdetect/ruby.vim
2017-01-09 16:11:47 -05:00
chocolateboy
00033e1875 Perl type: add "*.t"
https://github.com/petdance/ack2/blob/2.15_02/ConfigDefault.pm#L155
2017-01-09 16:11:47 -05:00
chocolateboy
5aea517fb4 add Crystal type: "Projectfile", "*.cr"
https://en.wikipedia.org/wiki/Crystal_(programming_language)
https://github.com/rhysd/vim-crystal/blob/master/ftdetect/crystal.vim
2017-01-09 16:11:47 -05:00
Daniel Luz
073ff35ebb Sync documented threads cap to code. 2017-01-08 17:02:57 -05:00
Daniel Luz
c4633ff187 Remove trivial condition. 2017-01-08 17:02:57 -05:00
Andrew Gallant
97e6873b38 Fix type compose test. 2017-01-07 22:50:38 -05:00
Ian Kerins
ed01e80a79 Provide a mechanism to compose type definitions
This extends the syntax of the --type-add flag to allow including the globs of
other already defined types.

Fixes #83.
2017-01-07 18:14:24 -05:00
Andrew Gallant
8f7b9be356 Add docs for shell completion files.
Add small howtos for installing shell completion files to the README and
the man page.

They are still incomplete. We're missing Zsh and PowerShell.

Fixes #262
2017-01-06 22:52:57 -05:00
Andrew Gallant
851799f42b Fix spacing issue in --help output. 2017-01-06 22:45:12 -05:00