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

190 Commits

Author SHA1 Message Date
Andrew Gallant
d65966efbc ignore: fix performance regression on Windows
This commit fixes a performance regression in Windows that resulted from
fallout from fixing #705. In particular, we introduced an additional
stat call for every single directory entry, which can be quite
disastrous for performance.

There is a corresponding companion PR that fixes the same bug in
walkdir: https://github.com/BurntSushi/walkdir/pull/96

Fixes #820
2018-02-20 19:50:52 -05:00
Andrey Kolomoets
f3a9ced82c types: add csv 2018-02-19 20:59:15 -05:00
Andrew Gallant
18f549d289
ignore: fix symlink following on Windows
This commit fixes a bug where symlinks were always being followed on
Windows, even if the user did not request it. This only impacts the
parallel iterator.

This is a regression from the fallout of fixing #705.

Fixes #824
2018-02-19 20:52:37 -05:00
Andrew Gallant
361698b90a
ignore: fix improper hidden filtering
This commit fixes a bug where `rg --hidden .` would behave differently
with respect to ignore filtering than `rg --hidden ./`. In particular,
this was due to a bug where the directory name `.` caused the leading
`.` in a hidden directory to get stripped, which in turn caused the
ignore rules to fail.

Fixes #807
2018-02-14 18:16:38 -05:00
David Peter
b71a110ccf ignore: fix custom ignore name bug
This commit fixes a bug in the handling of custom gitignore file names.
Previously, the directory walker would check for whether there were any
ignore rules present, but this check didn't incorporate the custom gitignore
rules. At a high level, this permits custom gitignore names to be used
even if no other source of gitignore rules is used.

Fixes #800
2018-02-14 06:53:26 -05:00
unsignedint
5c1af3c25d types: add VHDL 2018-02-13 07:32:16 -05:00
Andrew Gallant
56341973ee
ignore: release 0.4.0 2018-02-11 13:42:59 -05:00
Andrew Gallant
a431160d4c
globset: release 0.3.0 2018-02-11 13:41:36 -05:00
Andrew Gallant
3535047094 logger: drop env_logger
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-02-04 10:40:20 -05:00
Andrew Gallant
e36b65a11a
windows: fix OneDrive traversals
This commit fixes a bug on Windows where directory traversals were
completely broken when attempting to scan OneDrive directories that use
the "file on demand" strategy.

The specific problem was that Rust's standard library treats OneDrive
directories as reparse points instead of directories, which causes
methods like `FileType::is_file` and `FileType::is_dir` to always return
false, even when retrieved via methods like `metadata` that purport to
follow symbolic links.

We fix this by peppering our code with checks on the underlying file
attributes exposed by Windows. We consider an entry a directory if and
only if the directory bit is set on the attributes. We are careful to
make sure that the code remains the same on non-Windows platforms.

Note that we also bump the dependency on `walkdir`, which contains a
similar fix for its traversals.

This bug is recorded upstream:
https://github.com/rust-lang/rust/issues/46484

Upstream also has a pending PR:
https://github.com/rust-lang/rust/pull/47956

Fixes #705
2018-02-01 21:11:02 -05:00
Balaji Sivaraman
f007f940c5 search: add support for searching compressed files
This commit adds opt-in support for searching compressed files during
recursive search. This behavior is only enabled when the
`-z/--search-zip` flag is passed to ripgrep. When enabled, a limited set
of common compression formats are recognized via file extension, and a
new process is spawned to perform the decompression. ripgrep then
searches the stdout of that spawned process.

Closes #539
2018-01-30 09:13:53 -05:00
ptzz
3cb4d1337e ignore: support custom file names
This commit adds support for ignore files with custom names. This
allows for application specific ignorefile names, e.g. using
`.fdignore` for `fd`.

See also: https://github.com/BurntSushi/ripgrep/issues/673

See also: https://github.com/sharkdp/fd/issues/156
2018-01-29 16:06:05 -05:00
Michael Salihi
ed9150c9b4 types: add Smarty tpl
It is used by Prestashop CMS and more.
2018-01-29 14:12:02 -05:00
dana
51864c13fc ignore: fix handling of / in patterns
This commit makes handling of patterns containing a `/`
match actual git behaviour and the specification written
in `man gitignore`.

Fixes #761
2018-01-29 14:10:59 -05:00
Arvid Gerstmann
35f802166d types: add gn type
This is for Google's new build system.
2018-01-17 08:49:01 -05:00
Arvid Gerstmann
bba2d56292 types: add hxx to the cpp type 2018-01-17 08:47:23 -05:00
Hendrik Sollich
012880914b types: add webidl (*.webidl) 2018-01-14 11:20:21 -05:00
Hendrik Sollich
832f5baf1a types: add webidl 2018-01-12 19:48:50 -05:00
dana
a6d3a959eb types: yarn.lock is not YAML
Fixes #747
2018-01-12 19:35:46 -05:00
Mridul Singhai
ab2e8190e7 types: add Apache avro 2018-01-11 18:47:19 -05:00
Eitan Adler
74e96b498c Update types.rs 2018-01-09 07:29:44 -05:00
Eitan Adler
7e0fa1c6be Add a type for man pages 2018-01-09 07:29:44 -05:00
Balaji Sivaraman
b6177f0459 cleanup: replace try! with ? 2018-01-01 09:22:35 -05:00
Igor Gnatenko
5e73075ef5 deps: bump lazy_static to 1 2017-12-30 16:50:18 -05:00
Lilian A. Moraru
636bbc7c8f Speeding CI builds 2017-12-19 08:16:31 -05:00
M Pacer
231698f802 switch nb to jupyter 2017-11-22 06:56:30 -05:00
M Pacer
3e8b44619d add notebook file extensions to types 2017-11-22 06:56:30 -05:00
David Barsky
2c84825ccb Bump Cargo.toml version in ReadMe from 0.2 to 0.3 2017-11-17 17:57:57 -05:00
Zoltan Kalmar
948821753c Add Google Closure Templates type (.soy) 2017-11-16 07:07:56 -05:00
Igor Gnatenko
d2a3b61220 bump crossbeam to 0.3 2017-11-10 13:08:34 -05:00
Jesse Claven
acb57eb4ad Add Protocol Buffer file type. 2017-11-08 08:17:42 -05:00
Martin Lindhe
c794ef2f04 fix some typos 2017-11-01 07:10:54 -04:00
Brian Campbell
8b9eba2147 Properly match the rules "**/" and "!**/"
When processing a rule that ends in a slash, we strip it off and set the
`is_only_dir` flag.  We then apply the rule that paths that aren't
absolute should be given an implicit `**/` prefix, while avoiding
adding that prefix if it already exists.

However, this means that we miss the case in which we had already
stripped off the trailing slash and set `is_only_dir`.  Correct this
by also explicitly checking for that case.

Fixes #649
2017-11-01 07:10:33 -04:00
Andrew Gallant
8c8c83a1f8
deps: bump ignore to 0.3.1 2017-10-22 10:31:42 -04:00
Andrew Gallant
5714dbde09
ignore: partially revert symlink loop check optimization
This optimization wasn't tested too carefully, and it seems to result
in a massive amount of file handles open simultaneously. This is likely
a result of the parallel iterator, where many directories are being
traversed simultaneously.

Fixes #648
2017-10-22 10:31:34 -04:00
Andrew Gallant
efa4de8126
cargo: bump to 0.7.0 2017-10-21 22:40:10 -04:00
Andrew Gallant
1bf9d29259
ignore: be fastidious with file handles
This commit fixes the symlink loop checker in the parallel directory
traverser to open fewer handles at the expense of keeping handles held
open longer.

This roughly matches the corresponding change in walkdir:
5bcc5b87ee

Fixes #633
2017-10-21 22:40:10 -04:00
Andrew Gallant
cd575d99f8
ignore: upgrade to walkdir 2
The uninteresting bits of this commit involve mechanical changes for
updates to walkdir 2. The more interesting bits of this commit are the
breaking changes, although none of them should require any significant
change on users of this library. The breaking changes are as follows:

* `DirEntry::path_is_symbolic_link` has been renamed to
  `DirEntry::path_is_symlink`. This matches the conventions in the
  standard library, and also the corresponding name change in walkdir.
* Removed the `From<walkdir::Error> for ignore::Error` impl. This was
  intended to only be used internally, but was the only thing that
  made `walkdir` a public dependency of `ignore`. Therefore, we remove
  it since it seems unnecessary.
* Renamed `WalkBuilder::sort_by` to `WalkBuilder::sort_by_file_name`,
  and changed the type of the comparator from

    Fn(&OsString, &OsString) -> cmp::Ordering + 'static

  to

    Fn(&OsStr, &OsStr) -> cmp::Ordering + Send + Sync + 'static

  The corresponding change in `walkdir` retains the `sort_by` name, but
  gives the comparator a pair of `&DirEntry` values instead of a pair
  of `&OsStr` values. Ideally, `ignore` would hand off its own pair of
  `&ignore::DirEntry` values, but this requires more design work. So for
  now, we retain previous functionality, but leave room to make a proper
  `sort_by` method.

[breaking-change]
2017-10-21 22:40:09 -04:00
Andrew Gallant
1267f01c24
deps: upgrade to memchr 2 2017-10-21 22:40:09 -04:00
James Smith
db14046de4 Add purescript to built-in types
Purescript is a functional language that compiles to javascript (https://github.com/purescript/purescript)
2017-10-12 20:02:25 -04:00
dana
353806b87a Type improvements (config, license, sh, systemd, &c.)
- Add `license` type for various copyright/licence files
- Add `systemd` type for systemd config/unit files
- Update existing `config`, `jinja`, `json`, `sh`, `sql`, `xml`, `yaml` types
- Minor formatting improvements
2017-10-08 08:05:28 -04:00
Félix Cantournet
413178bc2c Add support for Dockerfiles filtering 2017-10-08 08:02:31 -04:00
Tri Nguyen
214f2bef66 add support for terraform file type 2017-09-23 11:29:09 -04:00
Philip Munksgaard
7eb1dd129e Add support for Standard ML file types 2017-09-04 07:26:47 -04:00
Alex Burka
a5f82e8826 ignore: add grouped toggle for standard filters 2017-09-02 12:28:59 -04:00
Jesse Claven
ca6bd648ab Add Elm file type. 2017-08-30 06:46:31 -04:00
Alex Burka
82d101907a ignore: document git_global enabled by default 2017-08-26 14:49:40 -04:00
Lilian A. Moraru
dbc91644fd Types extension and Yocto renaming to BitBake 2017-08-23 17:52:24 -04:00
Gergő Pintér
3d9acdab18 Add short key for julia type
Fixes #574
2017-08-16 10:46:13 -04:00
Andrew Gallant
92e5fad27d
ignore-0.2.2 2017-07-17 17:56:33 -04:00
Behnam Esfahbod
0668c74ed4 [ignore] Fix matched_path_or_any_parents() for patterns ending in slash
In `matched_path_or_any_parents()` implementation, we missed the point
that when we start walking up the tree, we have to set `is_dir` to
`true`, so path `ROOT/a/b/c` matches pattern `/a/`, although the
original path is not a dir.
2017-07-13 08:44:09 -04:00
Andrew Gallant
f5337329f4
ignore-0.2.1 2017-07-12 22:08:53 -04:00
Behnam Esfahbod ✅
84f4b4ef68 [ignore] Add extensive test for gitignore matching (#551)
[ignore] tests and new matched_path_or_any_parents method

The test data (gitignore rules and expected result) is based on the test
repo at <https://github.com/behnam/gitignore-test>.

The new `matched_path_or_any_parents` method fixes a bug
in gitignore matching where rules of form `<dir>/*` result in ignoring
only first-level files, but no deep files. This is not correct, as `<dir>/*`
matches the first-level directories under `<dir>`, resulting all to be
ignored. The new method fixes it by trying to match all parents in the
path against the gitignore rules.

The new method is necessary because it necessarily entails a
performance hit for trying to match all parents.
2017-07-12 22:06:08 -04:00
Jordan Danford
c8a5a7a3f4 Fix minor grammar issues in docs for ignore::Walk 2017-07-06 06:58:14 -04:00
Peter S Panov
4047d9db71 add --iglob flag
Working with Chris Stadler, implemented
https://github.com/BurntSushi/ripgrep/issues/163#issuecomment-300012592
2017-07-03 06:52:52 -04:00
Jordan Danford
4683a325fa Update version of ignore crate in README.md 2017-07-02 15:46:25 -04:00
Bryan Richter
b6f1e5db1a Add cabal files for Haskell packages 2017-06-27 16:24:02 -04:00
Sid-Ali Teir
e0989ef13b add yocto file types 2017-06-12 19:02:21 -04:00
Gent Bajraj
45e850aff7 Add julia as file type 2017-06-12 11:39:19 -04:00
Brian Gianforcaro
ab70815ea2 Add "msbuild" filetype for msbuild related files
This commit adds a "msbuild" filetype grouping, with
a few different file types being mapped to this grouping:

- MSBuild project files: .csproj, .vcxproj, .fsproj, .proj
- MSBuild shared property files: .props
- MSBuild shared targets files: .targets
2017-06-12 07:48:31 -04:00
Brian Gianforcaro
27f97db510 Add .inl as one of the c++ file typee definitions.
.inl files are often used by convention to include
both inline functions, or function templates.
2017-06-12 07:48:31 -04:00
Taryn Hill
506ad1f3cf Add a cshtml ignore type 2017-06-06 18:08:42 -04:00
Manuel Vives
cd6c54f5f4 Add support for QMake files 2017-05-24 16:44:22 -04:00
Andrew Gallant
5a666b042d
bump ripgrep, ignore, globset
The `ignore` and `globset` crates both got breaking changes in the
course of fixing #444, so increase 0.x to 0.(x+1).
2017-05-11 19:12:20 -04:00
Andrew Gallant
c50b8b4125 Add better error messages for invalid globs.
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-04-12 18:14:23 -04:00
Bryan Richter
1f2a9b0306 Add nix 2017-04-12 18:10:59 -04:00
Andrew Gallant
487713aa34 bump ignore 2017-04-09 09:45:00 -04:00
Andrew Gallant
685cc6c562 Add vim type.
It's the same as the vimscript type, but shorter and more obvious.

Fixes #415
2017-03-21 07:56:49 -04:00
Andrew Gallant
c648eadbaa Bump and update deps. 2017-03-12 21:33:13 -04:00
Joshua Horwitz
b3fd0df94b Fixes #394 - Added in svg to the types file 2017-03-12 19:52:01 -04:00
Andrew Gallant
c1b841e934 Add license files to each crate.
Fixes #381
2017-03-12 16:57:15 -04:00
Andrew Gallant
f5ede0e319 Add scss and ejs.
We add scss to the existing `css` file type and `ejs` to the existing
`html` file type.

Fixes #393
2017-03-12 16:51:55 -04:00
Andrew Gallant
80e91a1f1d Fix leading slash bug when used with !.
When writing paths like `!/foo` in gitignore files (or when using the
-g/--glob flag), the presence of `!` would prevent the gitignore builder
from noticing the leading slash, which causes absolute path matching to
fail.

Fixes #405
2017-03-12 15:51:17 -04:00
Marc Tiehuis
71585f6d47 Reduce unnecessary stat calls for max_filesize 2017-03-08 10:17:18 -05:00
tiehuis
49fd668712 Add file size exclusion to walker
A maximum filesize can be specified as an argument to a `WalkBuilder`.
If a file exceeds the specified size it will be ignored as part of the
resulting file/directory set.

The filesize limit never applies to directories.
2017-03-08 10:17:18 -05:00
deepy
796eaab0d7 Add .log as FileType 2017-02-23 11:41:32 -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
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
057ed6305a 0.4.0 2017-01-13 23:46:21 -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
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
b65a8c353b Add --sort-files flag.
When used, parallelism is disabled but the results are sorted by file
path.

Closes #263
2017-01-06 22:43:59 -05:00
Andrew Gallant
95cea77625 Tweak the parallel directory iterator.
This commit fixes two issues.

First, the iterator was executing the callback for every child of a
directory in a single thread. Therefore, if the walker was run over a
single directory, then no parallelism is used. We tweak the iterator
slightly so that we don't fall into this trap.

The second issue is a bit more subtle. In particular, we don't use the
blocking semantics of MsQueue because we *don't know when iteration
finishes*. This means that if there are a bunch of idle workers because
there is no work available to them, then they will spin and burn the
CPU. One case where this crops up is if you pipe the output of ripgrep
into `less` *and* the total number of files to search is fewer than the
number of threads ripgrep uses. We "fix" this with a very stupid
heuristic: when the queue yields no work, we sleep the thread for 1ms.
This still pegs the CPU, but not nearly as much as before.

If one really want to avoid this behavior when using ripgrep, then `-j1`
can be used to disable parallelism.

Fixes #258
2017-01-06 21:43:49 -05:00
Jason Shirk (POWERSHELL)
f7a2fe30d4 Add powershell as a known file type 2017-01-06 08:18:15 -05:00
Andrew Gallant
163e00677a Update to regex 0.2. 2017-01-01 01:03:21 -05:00
Andrew Gallant
d58236fbdc bump various versions 2016-12-30 15:44:08 -05:00
Matěj Cepl
932875684e Add types for handling SWIG files. (#297)
SWIG from http://swig.org/

Fixes #296
2016-12-29 21:01:10 -05:00
Andrew Gallant
084d3f4911 Small code cleanups. 2016-12-24 10:06:37 -05:00
Andrew Gallant
bb70f96743 Fix a non-termination bug.
This was a very silly bug. Instead of creating a particular atomic once
and cloning it, we created a new value for each worker.

Fixes #279
2016-12-12 06:55:49 -05:00
Andrew Gallant
20bcb8d883 ignore-0.1.6 2016-12-05 20:11:48 -05:00
Andrew Gallant
7282706b42 Fix bug reading root symlink.
When give an explicit file path on the command line like `foo` where `foo`
is a symlink, ripgrep should follow it even if `-L` isn't set. This is
consistent with the behavior of `foo/`.

Fixes #256
2016-12-05 20:05:57 -05:00
Andrew Gallant
08514e8e6c Merge pull request #253 from SimenB/stylus
Add stylus type
2016-11-28 17:40:07 -05:00
Simen Bekkhus
687e846944
Add stylus type 2016-11-25 15:24:27 +01:00