1
0
mirror of https://github.com/BurntSushi/ripgrep.git synced 2025-04-19 09:02:15 +02:00

Allow (and ignore) whitespace-only lines in .gitignore files

Git considers these to be blank lines.
This commit is contained in:
Tom Jackson 2016-09-26 09:34:32 -07:00 committed by Andrew Gallant
parent 104d740f76
commit 20ccd441f2

View File

@ -283,12 +283,15 @@ impl GitignoreBuilder {
from: P, from: P,
mut line: &str, mut line: &str,
) -> Result<(), Error> { ) -> Result<(), Error> {
if line.is_empty() || line.starts_with("#") { if line.starts_with("#") {
return Ok(()); return Ok(());
} }
if !line.ends_with("\\ ") { if !line.ends_with("\\ ") {
line = line.trim_right(); line = line.trim_right();
} }
if line.is_empty() {
return Ok(());
}
let mut pat = Pattern { let mut pat = Pattern {
from: from.as_ref().to_path_buf(), from: from.as_ref().to_path_buf(),
original: line.to_string(), original: line.to_string(),