mirror of
https://github.com/BurntSushi/ripgrep.git
synced 2025-07-25 17:21:57 -07:00
Compare commits
2 Commits
grep-print
...
ignore-0.3
Author | SHA1 | Date | |
---|---|---|---|
|
71b5b9c22c | ||
|
3f505931bd |
4
Cargo.lock
generated
4
Cargo.lock
generated
@@ -8,7 +8,7 @@ dependencies = [
|
||||
"encoding_rs 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"env_logger 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"grep 0.1.7",
|
||||
"ignore 0.3.0",
|
||||
"ignore 0.3.1",
|
||||
"lazy_static 0.2.9 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"libc 0.2.32 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
@@ -137,7 +137,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "ignore"
|
||||
version = "0.3.0"
|
||||
version = "0.3.1"
|
||||
dependencies = [
|
||||
"crossbeam 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"globset 0.2.1",
|
||||
|
@@ -36,7 +36,7 @@ clap = "2.26"
|
||||
encoding_rs = "0.7"
|
||||
env_logger = { version = "0.4", default-features = false }
|
||||
grep = { version = "0.1.7", path = "grep" }
|
||||
ignore = { version = "0.3.0", path = "ignore" }
|
||||
ignore = { version = "0.3.1", path = "ignore" }
|
||||
lazy_static = "0.2"
|
||||
libc = "0.2"
|
||||
log = "0.3"
|
||||
|
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "ignore"
|
||||
version = "0.3.0" #:version
|
||||
version = "0.3.1" #:version
|
||||
authors = ["Andrew Gallant <jamslam@gmail.com>"]
|
||||
description = """
|
||||
A fast library for efficiently matching ignore files such as `.gitignore`
|
||||
|
@@ -21,7 +21,6 @@ use std::sync::{Arc, RwLock};
|
||||
use gitignore::{self, Gitignore, GitignoreBuilder};
|
||||
use pathutil::{is_hidden, strip_prefix};
|
||||
use overrides::{self, Override};
|
||||
use same_file::Handle;
|
||||
use types::{self, Types};
|
||||
use {Error, Match, PartialErrorBuilder};
|
||||
|
||||
@@ -96,9 +95,6 @@ struct IgnoreInner {
|
||||
compiled: Arc<RwLock<HashMap<OsString, Ignore>>>,
|
||||
/// The path to the directory that this matcher was built from.
|
||||
dir: PathBuf,
|
||||
/// An open handle to the directory, for checking symlink loops in the
|
||||
/// parallel iterator.
|
||||
handle: Arc<Option<Handle>>,
|
||||
/// An override matcher (default is empty).
|
||||
overrides: Arc<Override>,
|
||||
/// A file type matcher.
|
||||
@@ -135,11 +131,6 @@ impl Ignore {
|
||||
&self.0.dir
|
||||
}
|
||||
|
||||
/// Return a handle to the directory of this matcher.
|
||||
pub fn handle(&self) -> Option<&Handle> {
|
||||
(*self.0.handle).as_ref()
|
||||
}
|
||||
|
||||
/// Return true if this matcher has no parent.
|
||||
pub fn is_root(&self) -> bool {
|
||||
self.0.parent.is_none()
|
||||
@@ -246,17 +237,9 @@ impl Ignore {
|
||||
errs.maybe_push(err);
|
||||
m
|
||||
};
|
||||
let handle = match Handle::from_path(dir) {
|
||||
Ok(handle) => Some(handle),
|
||||
Err(err) => {
|
||||
errs.push(Error::from(err).with_path(dir));
|
||||
None
|
||||
}
|
||||
};
|
||||
let ig = IgnoreInner {
|
||||
compiled: self.0.compiled.clone(),
|
||||
dir: dir.to_path_buf(),
|
||||
handle: Arc::new(handle),
|
||||
overrides: self.0.overrides.clone(),
|
||||
types: self.0.types.clone(),
|
||||
parent: Some(self.clone()),
|
||||
@@ -467,14 +450,9 @@ impl IgnoreBuilder {
|
||||
}
|
||||
gi
|
||||
};
|
||||
let handle = match Handle::from_path(&self.dir) {
|
||||
Ok(handle) => Some(handle),
|
||||
Err(_) => None,
|
||||
};
|
||||
Ignore(Arc::new(IgnoreInner {
|
||||
compiled: Arc::new(RwLock::new(HashMap::new())),
|
||||
dir: self.dir.clone(),
|
||||
handle: Arc::new(handle),
|
||||
overrides: self.overrides.clone(),
|
||||
types: self.types.clone(),
|
||||
parent: None,
|
||||
|
@@ -1312,7 +1312,10 @@ fn check_symlink_loop(
|
||||
Error::from(err).with_path(child_path).with_depth(child_depth)
|
||||
})?;
|
||||
for ig in ig_parent.parents().take_while(|ig| !ig.is_absolute_parent()) {
|
||||
if ig.handle().map_or(true, |parent| parent == &hchild) {
|
||||
let h = Handle::from_path(ig.path()).map_err(|err| {
|
||||
Error::from(err).with_path(child_path).with_depth(child_depth)
|
||||
})?;
|
||||
if hchild == h {
|
||||
return Err(Error::Loop {
|
||||
ancestor: ig.path().to_path_buf(),
|
||||
child: child_path.to_path_buf(),
|
||||
|
Reference in New Issue
Block a user