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
This commit is contained in:
Andrew Gallant
2017-03-12 15:51:07 -04:00
parent d570f78144
commit 80e91a1f1d
3 changed files with 22 additions and 1 deletions

View File

@@ -1045,6 +1045,18 @@ clean!(regression_279, "test", ".", |wd: WorkDir, mut cmd: Command| {
assert_eq!(lines, "");
});
// See: https://github.com/BurntSushi/ripgrep/issues/405
clean!(regression_405, "test", ".", |wd: WorkDir, mut cmd: Command| {
wd.create_dir("foo/bar");
wd.create_dir("bar/foo");
wd.create("foo/bar/file1.txt", "test");
wd.create("bar/foo/file2.txt", "test");
cmd.arg("-g").arg("!/foo/**");
let lines: String = wd.stdout(&mut cmd);
assert_eq!(lines, "bar/foo/file2.txt:test\n");
});
// See: https://github.com/BurntSushi/ripgrep/issues/7
sherlock!(feature_7, "-fpat", "sherlock", |wd: WorkDir, mut cmd: Command| {
wd.create("pat", "Sherlock\nHolmes");