diff --git a/src/cargo/sources/path.rs b/src/cargo/sources/path.rs index 7765906977f..ee2e6fea47f 100644 --- a/src/cargo/sources/path.rs +++ b/src/cargo/sources/path.rs @@ -626,8 +626,11 @@ fn list_files_gix( .filter(|res| { // Don't include Cargo.lock if it is untracked. Packaging will // generate a new one as needed. + // Also don't include untrackable directory entries, like FIFOs. res.as_ref().map_or(true, |item| { - !(item.entry.status == Status::Untracked && item.entry.rela_path == "Cargo.lock") + item.entry.disk_kind != Some(gix::dir::entry::Kind::Untrackable) + && !(item.entry.status == Status::Untracked + && item.entry.rela_path == "Cargo.lock") }) }) .map(|res| res.map(|item| (item.entry.rela_path, item.entry.disk_kind))) @@ -751,7 +754,8 @@ fn list_files_walk( for entry in walkdir { match entry { Ok(entry) => { - if !entry.file_type().is_dir() { + let file_type = entry.file_type(); + if file_type.is_file() || file_type.is_symlink() { ret.push(entry.into_path()); } } diff --git a/tests/testsuite/git.rs b/tests/testsuite/git.rs index 40e9db15c86..c63d355c445 100644 --- a/tests/testsuite/git.rs +++ b/tests/testsuite/git.rs @@ -4221,3 +4221,41 @@ src/lib.rs "#]]) .run(); } + +#[cargo_test] +#[cfg(unix)] +fn simple_with_fifo() { + let git_project = git::new("foo", |project| { + project + .file( + "Cargo.toml", + r#" + [package] + name = "foo" + version = "0.1.0" + edition = "2015" + "#, + ) + .file("src/main.rs", "fn main() {}") + }); + + std::process::Command::new("mkfifo") + .current_dir(git_project.root()) + .arg(git_project.root().join("blocks-when-read")) + .status() + .expect("a FIFO can be created"); + + // Avoid actual blocking even in case of failure, assuming that what it lists here + // would also be read eventually. + git_project + .cargo("package -l") + .with_stdout_data(str![[r#" +.cargo_vcs_info.json +Cargo.lock +Cargo.toml +Cargo.toml.orig +src/main.rs + +"#]]) + .run(); +} diff --git a/tests/testsuite/package.rs b/tests/testsuite/package.rs index 1740de4ac77..e349f744ce8 100644 --- a/tests/testsuite/package.rs +++ b/tests/testsuite/package.rs @@ -6873,3 +6873,38 @@ See https://doc.rust-lang.org/cargo/reference/manifest.html#package-metadata for "#]]) .run(); } + +#[cargo_test] +#[cfg(unix)] +fn simple_with_fifo() { + let p = project() + .file( + "Cargo.toml", + r#" + [package] + name = "foo" + version = "0.1.0" + edition = "2015" + "#, + ) + .file("src/main.rs", "fn main() {}") + .build(); + + std::process::Command::new("mkfifo") + .current_dir(p.root()) + .arg(p.root().join("blocks-when-read")) + .status() + .expect("a FIFO can be created"); + + // Avoid actual blocking even in case of failure, assuming that what it lists here + // would also be read eventually. + p.cargo("package -l") + .with_stdout_data(str![[r#" +Cargo.lock +Cargo.toml +Cargo.toml.orig +src/main.rs + +"#]]) + .run(); +}