Skip to content

Commit 32e1118

Browse files
authored
Stop following symlinks for files (#45)
When the symlink pointed to a path that did *not* have the git root as a prefix, this could lead to a panic. Additionally, *not* following symlinks is closer to the intended behavior of listing items under each directory.
1 parent ddf6002 commit 32e1118

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

src/tree/mod.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ use owo_colors::AnsiColors;
1313
use owo_colors::OwoColorize;
1414
use std::fmt::Display;
1515
use std::io::{self, Write, stdout};
16-
use std::path::{Path, PathBuf};
16+
use std::path::{self, Path, PathBuf};
1717

1818
mod builder;
1919
mod charset;
@@ -285,9 +285,8 @@ where
285285
.expect("Git root should exist and non-final components should be directories");
286286

287287
let path = path.as_ref();
288-
let path = path
289-
.canonicalize()
290-
.expect("Path should exist and non-final components should be directories");
288+
let path = path::absolute(path)
289+
.expect("Path should be non-empty and should be able to get the current directory");
291290
let path = path
292291
.strip_prefix(git_root)
293292
.expect("Path should have the git root as a prefix");

0 commit comments

Comments
 (0)