Skip to content

Commit 4546889

Browse files
committed
Assure cross-fs check doesn't break if cursor is currently empty
A pop on the cursor might leave it empty, which usually isn't a problem as we push paths on top of it for file tests. Trying to get metadata on an empty path is invalid though, so we replace it with '.' if needed.
1 parent 277c41f commit 4546889

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

git-discover/src/upwards.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,13 @@ pub(crate) mod function {
133133

134134
#[cfg(unix)]
135135
if current_height != 0 && !cross_fs {
136-
let metadata = cursor.metadata().map_err(|_| Error::InaccessibleDirectory {
136+
let metadata = if cursor.as_os_str().is_empty() {
137+
Path::new(".")
138+
} else {
139+
cursor.as_ref()
140+
}
141+
.metadata()
142+
.map_err(|_| Error::InaccessibleDirectory {
137143
path: cursor.to_path_buf(),
138144
})?;
139145

0 commit comments

Comments
 (0)