From 91781609a54e42fa7009b61f349c03585e6eefbe Mon Sep 17 00:00:00 2001 From: Sebastian Thiel Date: Sat, 23 Mar 2024 08:52:12 +0100 Subject: [PATCH] Assure top-level refspecs and tailing '/' for target prefix Top-level pathspecs are needed to assure they are not affected by the CWD. The trailing `/` in `'target` is needed to assure excluded items are in a folder, and that only entries in that folder are extracted from the index. --- src/cargo/sources/path.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/cargo/sources/path.rs b/src/cargo/sources/path.rs index f6817cba24f..7d56b7194f9 100644 --- a/src/cargo/sources/path.rs +++ b/src/cargo/sources/path.rs @@ -13,7 +13,7 @@ use crate::util::{internal, CargoResult, GlobalContext}; use anyhow::Context as _; use cargo_util::paths; use filetime::FileTime; -use gix::bstr::ByteVec; +use gix::bstr::{BString, ByteVec}; use gix::dir::entry::Status; use ignore::gitignore::GitignoreBuilder; use tracing::{trace, warn}; @@ -498,7 +498,7 @@ impl<'gctx> PathSource<'gctx> { let pkg_path = pkg.root(); let repo_relative_pkg_path = pkg_path.strip_prefix(root).unwrap_or(Path::new("")); let target_prefix = gix::path::to_unix_separators_on_windows(gix::path::into_bstr( - repo_relative_pkg_path.join("target"), + repo_relative_pkg_path.join("target/"), )); let package_prefix = gix::path::to_unix_separators_on_windows(gix::path::into_bstr(repo_relative_pkg_path)); @@ -509,7 +509,7 @@ impl<'gctx> PathSource<'gctx> { include.push_str(package_prefix.as_ref()); // Exclude the target directory. - let mut exclude = BString::from(":!"); + let mut exclude = BString::from(":!/"); exclude.push_str(target_prefix.as_ref()); vec![include, exclude]