Skip to content

Commit 09c3329

Browse files
committed
Strip trailing whitespace in gitignore patterns.
Fixes BurntSushi#38.
1 parent 27a5941 commit 09c3329

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/gitignore.rs

+4
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,9 @@ impl GitignoreBuilder {
279279
if line.is_empty() || line.starts_with("#") {
280280
return Ok(());
281281
}
282+
if !line.ends_with("\\ ") {
283+
line = line.trim_right();
284+
}
282285
let mut pat = Pattern {
283286
from: from.as_ref().to_path_buf(),
284287
original: line.to_string(),
@@ -401,6 +404,7 @@ mod tests {
401404
ignored!(ig27, ROOT, "foo/", "xyz/foo", true);
402405
ignored!(ig28, ROOT, "src/*.rs", "src/grep/src/main.rs");
403406
ignored!(ig29, "./src", "/llvm/", "./src/llvm", true);
407+
ignored!(ig30, ROOT, "node_modules/ ", "node_modules", true);
404408

405409
not_ignored!(ignot1, ROOT, "amonths", "months");
406410
not_ignored!(ignot2, ROOT, "monthsa", "months");

0 commit comments

Comments
 (0)