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

493 Commits

Author SHA1 Message Date
Andrew Gallant
2b15832655 update brew formula to 0.2.0 2016-09-25 22:50:50 -04:00
Andrew Gallant
b1c52b52d6 0.2.0 2016-09-25 22:32:14 -04:00
Andrew Gallant
109bc3f78e bump grep to 0.1.3 2016-09-25 22:30:17 -04:00
Andrew Gallant
b62195b33f grep 0.1.3 2016-09-25 22:29:35 -04:00
Andrew Gallant
baebfd7add changelog 0.2.0 2016-09-25 22:27:58 -04:00
Andrew Gallant
19e405e5c5 fix windows 2016-09-25 21:48:01 -04:00
Andrew Gallant
f85822266f Don't use an intermediate buffer when --threads=1.
Fixes #8
2016-09-25 21:27:17 -04:00
Andrew Gallant
b034b77798 Don't replace NUL bytes when searching binary files as text.
This was a result of misinterpreting a feature in grep where NUL bytes
are replaced with \n. The primary reason for doing this is to avoid
excessive memory usage on truly binary data. However, grep only does this
when searching binary files as if they were binary, and which only reports
whether the file matched or not. When grep is told to search binary data
as text (the -a/--text flag), then it doesn't do any replacement so we
shouldn't either.

In general, this makes sense, because the user is essentially asserting
that a particular file that looks like binary is actually text. In that
case, we shouldn't try to replace any NUL bytes.

ripgrep doesn't actually support searching binary data for whether it
matches or not, so we don't actually need the replace_buf function.
However, it does seem like a potentially useful feature.
2016-09-25 21:26:49 -04:00
Andrew Gallant
278e1168bf Make printing paths a bit faster.
It seems silly, but on *nix, we can just dump the bytes of the path
straight to the terminal. There's no need to do a UTF-8 check, which
can be costly when printing lots of matches.
2016-09-25 21:23:26 -04:00
Andrew Gallant
6a8051b258 Don't union inner literals of repetitions.
If we do, this results in extracting `foofoofoo` from `(\wfoo){3}`,
which is wrong. This does prevent us from extracting `foofoofoo` from
`foo{3}`, which is unfortunate, but we miss plenty of other stuff too.
Literal extracting needs a good rethink (all the way down into the regex
engine).

Fixes #93
2016-09-25 20:10:28 -04:00
Andrew Gallant
a13ac3e3d4 On Windows, always consider stdin to be a tty.
This means that `rg pat < file` won't do the expected thing and search
`fil`. Instead, it will recursively search the current directory for `pat`.
This isn't ideal, but is better than the previous behavior, which was to
wait for stdin when running `rg pat`, given the appearance of hanging
forever. The former is an important use case, but the latter is the
*central* use case of ripgrep, so we should make that work.

`rg` can still be used to search stdin on Windows, it just needs to be
done explicitly. e.g., `rg pat - < file` will search for `pat` in `file`.

Fixes #19
2016-09-25 20:00:29 -04:00
Andrew Gallant
a72467996b Fix Windows compilation error. 2016-09-25 20:00:29 -04:00
Andrew Gallant
9395076468 Merge pull request #92 from svenstaro/patch-1
ripgrep is now in [community]
2016-09-25 18:50:03 -04:00
Sven-Hendrik Haase
a12c63957b ripgrep is now in [community]
The README should reflect that.
2016-09-26 00:48:41 +02:00
Andrew Gallant
982265af70 Move --files-with-matches to less common options. 2016-09-25 18:32:41 -04:00
Andrew Gallant
ed94aedf27 Permit whitelisting hidden files in ignores.
Fixes #90
2016-09-25 18:31:41 -04:00
Andrew Gallant
fd5ae2f795 Add curly brace alternates to glob format.
Closes #80.
2016-09-25 17:28:23 -04:00
Andrew Gallant
3d6a39be06 Fix tests on Windows.
Mostly this is just using \\ instead of / in paths reported by the OS.
2016-09-25 15:45:51 -04:00
Andrew Gallant
e7839f2200 Merge pull request #71 from catchmrbharath/issue46
[Fixes #46] Use 1 less worker thread than number of threads
2016-09-25 15:02:38 -04:00
Andrew Gallant
9dc5464c84 Stop after first match is found with --quiet.
Fixes #77.
2016-09-25 15:01:29 -04:00
Andrew Gallant
95edcd4d3a Merge pull request #42 from andschwa/files-with-matches
Files with matches
2016-09-25 14:53:31 -04:00
Andrew Gallant
d97f404970 Stupid docopt.
It thinks `--type-clear is` is a flag spec.
2016-09-25 14:47:35 -04:00
Andrew Gallant
b2bbd46178 Clarify documentation of --type-add.
This explains it a bit more based on end user feedback. We also fix
the example, which was wrong.

Fixes #82.
2016-09-25 14:37:01 -04:00
Andrew Gallant
82542df5cb Merge pull request #84 from martinlindhe/ts
Add ts type for typescript
2016-09-25 11:33:11 -04:00
Martin Lindhe
e4329037aa Add ts type for typescript 2016-09-25 17:16:15 +02:00
Andrew Gallant
ab0d1c1c79 Be more conservative with stdin.
If no paths are given to ripgrep, only read from stdin if it's a file or
a FIFO. In particular, if something like `rg foo < /dev/null` is used,
then don't try to read from stdin.

Fixes #35, #81
2016-09-25 11:14:54 -04:00
Andrew Gallant
2015c56e8d Merge pull request #62 from martinlindhe/js-wc
--type js: include more extensions
2016-09-25 11:10:47 -04:00
Martin Lindhe
23ad8b989d --type js: include more extensions 2016-09-25 17:06:13 +02:00
Andrew Schwartzmeyer
a8f3d9e87e Add --files-with-matches flag.
Closes #26.

Acts like --count but emits only the paths of files with matches,
suitable for piping to xargs. Both mmap and no-mmap searches terminate
after the first match is found. Documentation updated and tests added.
2016-09-24 21:40:17 -07:00
Bharath M R
9f1aae64f8 [Fixes #46] Use 1 less worker thread than number of threads
The main thread does directory traversal. Hence
number of threads = main Thread + number of worker threads.
We should have atleast one worker thread.
2016-09-24 19:48:26 -07:00
Andrew Gallant
1595f0faf5 Add --smart-case.
It does what it says on the tin.

Closes #70.
2016-09-24 21:51:04 -04:00
Andrew Gallant
8eeb0c0b60 Add --no-ignore-vcs flag.
This flag will respect .ignore but not .gitignore.

Closes #68.
2016-09-24 21:31:24 -04:00
Andrew Gallant
423f2a1927 Permit options with --help/--version.
Fixes #47.
2016-09-24 21:13:24 -04:00
Andrew Gallant
4b5e789a2a Strip trailing whitespace in gitignore patterns.
Fixes #38.
2016-09-24 20:56:24 -04:00
Andrew Gallant
37b731a048 Update brew package to 0.1.17.
Closes #58, Fixes #13
2016-09-24 20:51:07 -04:00
Andrew Gallant
a44735aa87 Tweak memory maps on darwin.
Namely, don't automatically pick memory maps on darwin, ever. They
appear slower than standard read calls.

Closes #36.
2016-09-24 20:48:05 -04:00
Andrew Gallant
6b2efd4d88 If a file is empty, still try to search it.
Files like /proc/cpuinfo will advertise themselves as a normal file with
size 0. Normally, this isn't a problem, but if ripgrep decides to use a
memory map, it skipped searching if the file was empty since it's an error
to memory map an empty file. Instead of returning 0, we should just fall
back to standard read calls.

Fixes #55.
2016-09-24 20:45:06 -04:00
Andrew Gallant
c8227e0cf3 Don't ignore first path when using --files.
This is a docopt oddity, but probably not a bug. If --files is given,
then just interpret the pattern (if not empty) as the first file path.

Fixes #64.
2016-09-24 20:22:02 -04:00
Andrew Gallant
b941c10b90 Fix directory whitelisting.
There was a bug in the translation from a gitignore pattern to a standard
glob where `!/dir` wasn't being interpreted as an absolute path.

Fixes #67.
2016-09-24 20:10:30 -04:00
Andrew Gallant
872a107658 Fix whitelisting precedence.
Once a file is known to be whitelisted, we shouldn't check any ancestor
gitignores.
2016-09-24 20:09:29 -04:00
Andrew Gallant
71ad9bf393 Fix trailing recursive globs in gitignore.
A standard glob of `foo/**` will match `foo`, but gitignore semantics
specify that `foo/**` should only match the contents of `foo` and not
`foo` itself. We capture those semantics by translating `foo/**` to
`foo/**/*`.

Fixes #30.
2016-09-24 19:44:06 -04:00
Andrew Gallant
f733e9ebe4 Fix typo.
Thanks @dmit!
2016-09-24 19:43:01 -04:00
Andrew Gallant
ce85df1d2e Clarify what rg does in --help.
Fixes #24.
2016-09-24 19:26:28 -04:00
Andrew Gallant
a6e3cab65a Add --no-filename flag.
When this flag is set, a filename is never shown for a match.

Closes #20
2016-09-24 19:24:24 -04:00
Andrew Gallant
7b860affbe Change the default output of --files to elide './'.
This is kind of a ticky-tack change. I do think ./ as a prefix is
reasonable default, *but* we strip ./ when showing search results, so it
does make sense to be consistent.

Fixes #21.
2016-09-24 19:18:48 -04:00
Andrew Gallant
af4dc78537 Update to docopt 0.6.85.
The new version won't panic if printing to stdout fails.

Fixes #22.
2016-09-24 19:14:19 -04:00
Andrew Gallant
9ce0484670 Clarify the documentation of the --type-* flags.
Fixes #15
2016-09-24 18:55:48 -04:00
Andrew Gallant
346bad7dfc Fix handling of absolute patterns in parent gitignore files.
If a gitignore file in a *parent* directory is used, then it must be
matched relative to the directory it's in. ripgrep wasn't actually
adhering to this rule. Consider an example:

  .gitignore
  src
    llvm
      foo

Where `.gitignore` contains `/llvm/` and `foo` contains `test`. When
running `rg test` at the top-level directory, `foo` is correctly searched.
If you `cd` into `src` and re-run the same search, `foo` is ignored because
the `/llvm/` pattern is interpreted with respect to the current working
directory, which is wrong. The problem is that the path of `llvm` is
`./llvm`, which makes it look like it should match.

We fix this by rebuilding the directory path of each file when traversing
gitignores in parent directories. This does come with a small performance
hit.

Fixes #25.
2016-09-24 18:40:50 -04:00
Andrew Gallant
56fe93d343 Fix an absolute path name bug.
Namely, if a .gitignore inside a sub-directory has an absolute pattern,
e.g., `/foo/`, then we should match it relative to the directory containing
the .gitignore.
2016-09-24 17:31:24 -04:00
Andrew Gallant
155676b474 Fixes #43. 2016-09-24 16:34:34 -04:00