diff options
author | Andrew Gallant <jamslam@gmail.com> | 2020-02-17 15:59:03 -0500 |
---|---|---|
committer | Andrew Gallant <jamslam@gmail.com> | 2020-02-17 17:16:28 -0500 |
commit | 52d7f474206eb517c7284448777ed839c0cae8bb (patch) | |
tree | 27a3896de5ad5b648984be5e4e3beb57ccda44d4 /tests | |
parent | 75cbe88fa2993bcb12cbbddb32670cba30527716 (diff) |
ignore: treat symbolic links to directories as directories
Due to how walkdir works if symlinks are not followed, symlinks to
directories are seen as simple files by ripgrep. This caused a panic
in some cases due to receiving a WalkEvent::Exit event without a
corresponding WalkEvent::Dir event.
This is fixed by looking at the metadata of the file in the case of a
symlink to determine if it's a directory. We are careful to only do
this stat check when the depth of the entry is 0, as this bug only
impacts us when 1) we aren't following symlinks generally and 2) the
user provides a symlinked directory that we do follow as a top-level
path to search.
Fixes #1389, Closes #1397
Diffstat (limited to 'tests')
-rw-r--r-- | tests/regression.rs | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/tests/regression.rs b/tests/regression.rs index 72f58590..29f15a27 100644 --- a/tests/regression.rs +++ b/tests/regression.rs @@ -747,6 +747,21 @@ rgtest!(r1334_crazy_literals, |dir: Dir, mut cmd: TestCommand| { ); }); +// See: https://github.com/BurntSushi/ripgrep/issues/1389 +rgtest!(r1389_bad_symlinks_no_biscuit, |dir: Dir, mut cmd: TestCommand| { + dir.create_dir("mydir"); + dir.create("mydir/file.txt", "test"); + dir.link_dir("mydir", "mylink"); + + let stdout = cmd.args(&[ + "test", + "--no-ignore", + "--sort", "path", + "mylink", + ]).stdout(); + eqnice!("mylink/file.txt:test\n", stdout); +}); + // See: https://github.com/BurntSushi/ripgrep/pull/1446 rgtest!(r1446_respect_excludes_in_worktree, |dir: Dir, mut cmd: TestCommand| { dir.create_dir("repo/.git/info"); |