mirror of
https://github.com/BurntSushi/ripgrep.git
synced 2025-07-31 12:12:00 -07:00
Compare commits
5 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
d8712daf27 | ||
|
7cbbef019f | ||
|
4d29d886e5 | ||
|
247a9398f4 | ||
|
4c3025ab1c |
12
CHANGELOG.md
12
CHANGELOG.md
@@ -1,3 +1,13 @@
|
||||
0.2.3
|
||||
=====
|
||||
Bug fixes:
|
||||
|
||||
* [BUG #164](https://github.com/BurntSushi/ripgrep/issues/164):
|
||||
Fixes a segfault on macos builds.
|
||||
* [BUG #167](https://github.com/BurntSushi/ripgrep/issues/167):
|
||||
Clarify documentation for --threads.
|
||||
|
||||
|
||||
0.2.2
|
||||
=====
|
||||
Packaging updates:
|
||||
@@ -13,7 +23,7 @@ Packaging updates:
|
||||
Feature enhancements:
|
||||
|
||||
* Added or improved file type filtering for CMake, config, Jinja, Markdown,
|
||||
Spark,
|
||||
Spark.
|
||||
* [FEATURE #109](https://github.com/BurntSushi/ripgrep/issues/109):
|
||||
Add a --max-depth flag for directory traversal.
|
||||
* [FEATURE #124](https://github.com/BurntSushi/ripgrep/issues/124):
|
||||
|
3
Cargo.lock
generated
3
Cargo.lock
generated
@@ -1,6 +1,6 @@
|
||||
[root]
|
||||
name = "ripgrep"
|
||||
version = "0.2.1"
|
||||
version = "0.2.2"
|
||||
dependencies = [
|
||||
"deque 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"docopt 0.6.86 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
@@ -17,6 +17,7 @@ dependencies = [
|
||||
"regex 0.1.77 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"rustc-serialize 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"term 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"thread_local 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"walkdir 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "ripgrep"
|
||||
version = "0.2.2" #:version
|
||||
version = "0.2.3" #:version
|
||||
authors = ["Andrew Gallant <jamslam@gmail.com>"]
|
||||
description = """
|
||||
Line oriented search tool using Rust's regex library. Combines the raw
|
||||
@@ -38,6 +38,7 @@ num_cpus = "1"
|
||||
regex = "0.1.77"
|
||||
rustc-serialize = "0.3"
|
||||
term = "0.4"
|
||||
thread_local = "0.2.7"
|
||||
walkdir = "0.1"
|
||||
|
||||
[target.'cfg(windows)'.dependencies]
|
||||
|
2
doc/rg.1
2
doc/rg.1
@@ -277,7 +277,7 @@ This is overridden by either \-\-case\-sensitive or \-\-ignore\-case.
|
||||
.TP
|
||||
.B \-j, \-\-threads \f[I]ARG\f[]
|
||||
The number of threads to use.
|
||||
Defaults to the number of logical CPUs (capped at 6).
|
||||
0 means use the number of logical CPUs (capped at 6).
|
||||
[default: 0]
|
||||
.RS
|
||||
.RE
|
||||
|
@@ -180,7 +180,7 @@ the raw speed of grep.
|
||||
--case-sensitive or --ignore-case.
|
||||
|
||||
-j, --threads *ARG*
|
||||
: The number of threads to use. Defaults to the number of logical CPUs
|
||||
: The number of threads to use. 0 means use the number of logical CPUs
|
||||
(capped at 6). [default: 0]
|
||||
|
||||
--version
|
||||
|
@@ -182,7 +182,7 @@ Less common options:
|
||||
either --case-sensitive or --ignore-case.
|
||||
|
||||
-j, --threads ARG
|
||||
The number of threads to use. Defaults to the number of logical CPUs
|
||||
The number of threads to use. 0 means use the number of logical CPUs
|
||||
(capped at 6). [default: 0]
|
||||
|
||||
--version
|
||||
|
@@ -27,9 +27,11 @@ use std::fmt;
|
||||
use std::fs::File;
|
||||
use std::io::{self, BufRead};
|
||||
use std::path::{Path, PathBuf};
|
||||
use std::sync::Arc;
|
||||
|
||||
use globset::{self, Candidate, GlobBuilder, GlobSet, GlobSetBuilder};
|
||||
use regex;
|
||||
use thread_local::ThreadLocal;
|
||||
|
||||
use pathutil::{is_file_name, strip_prefix};
|
||||
|
||||
@@ -87,6 +89,7 @@ pub struct Gitignore {
|
||||
patterns: Vec<Pattern>,
|
||||
num_ignores: u64,
|
||||
num_whitelist: u64,
|
||||
matches: Arc<ThreadLocal<RefCell<Vec<usize>>>>,
|
||||
}
|
||||
|
||||
impl Gitignore {
|
||||
@@ -133,27 +136,21 @@ impl Gitignore {
|
||||
|
||||
/// Like matched, but takes a path that has already been stripped.
|
||||
pub fn matched_stripped(&self, path: &Path, is_dir: bool) -> Match {
|
||||
thread_local! {
|
||||
static MATCHES: RefCell<Vec<usize>> = {
|
||||
RefCell::new(vec![])
|
||||
let _matches = self.matches.get_default();
|
||||
let mut matches = _matches.borrow_mut();
|
||||
let candidate = Candidate::new(path);
|
||||
self.set.matches_candidate_into(&candidate, &mut *matches);
|
||||
for &i in matches.iter().rev() {
|
||||
let pat = &self.patterns[i];
|
||||
if !pat.only_dir || is_dir {
|
||||
return if pat.whitelist {
|
||||
Match::Whitelist(pat)
|
||||
} else {
|
||||
Match::Ignored(pat)
|
||||
};
|
||||
}
|
||||
};
|
||||
MATCHES.with(|matches| {
|
||||
let mut matches = matches.borrow_mut();
|
||||
let candidate = Candidate::new(path);
|
||||
self.set.matches_candidate_into(&candidate, &mut *matches);
|
||||
for &i in matches.iter().rev() {
|
||||
let pat = &self.patterns[i];
|
||||
if !pat.only_dir || is_dir {
|
||||
return if pat.whitelist {
|
||||
Match::Whitelist(pat)
|
||||
} else {
|
||||
Match::Ignored(pat)
|
||||
};
|
||||
}
|
||||
}
|
||||
Match::None
|
||||
})
|
||||
}
|
||||
Match::None
|
||||
}
|
||||
|
||||
/// Returns the total number of ignore patterns.
|
||||
@@ -256,6 +253,7 @@ impl GitignoreBuilder {
|
||||
patterns: self.patterns,
|
||||
num_ignores: nignores as u64,
|
||||
num_whitelist: nwhitelist as u64,
|
||||
matches: Arc::new(ThreadLocal::default()),
|
||||
})
|
||||
}
|
||||
|
||||
|
@@ -16,6 +16,7 @@ extern crate num_cpus;
|
||||
extern crate regex;
|
||||
extern crate rustc_serialize;
|
||||
extern crate term;
|
||||
extern crate thread_local;
|
||||
extern crate walkdir;
|
||||
#[cfg(windows)]
|
||||
extern crate winapi;
|
||||
|
Reference in New Issue
Block a user