Skip to content

Commit 9178160

Browse files
committed
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.
1 parent dbf1b6a commit 9178160

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/cargo/sources/path.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ use crate::util::{internal, CargoResult, GlobalContext};
1313
use anyhow::Context as _;
1414
use cargo_util::paths;
1515
use filetime::FileTime;
16-
use gix::bstr::ByteVec;
16+
use gix::bstr::{BString, ByteVec};
1717
use gix::dir::entry::Status;
1818
use ignore::gitignore::GitignoreBuilder;
1919
use tracing::{trace, warn};
@@ -498,7 +498,7 @@ impl<'gctx> PathSource<'gctx> {
498498
let pkg_path = pkg.root();
499499
let repo_relative_pkg_path = pkg_path.strip_prefix(root).unwrap_or(Path::new(""));
500500
let target_prefix = gix::path::to_unix_separators_on_windows(gix::path::into_bstr(
501-
repo_relative_pkg_path.join("target"),
501+
repo_relative_pkg_path.join("target/"),
502502
));
503503
let package_prefix =
504504
gix::path::to_unix_separators_on_windows(gix::path::into_bstr(repo_relative_pkg_path));
@@ -509,7 +509,7 @@ impl<'gctx> PathSource<'gctx> {
509509
include.push_str(package_prefix.as_ref());
510510

511511
// Exclude the target directory.
512-
let mut exclude = BString::from(":!");
512+
let mut exclude = BString::from(":!/");
513513
exclude.push_str(target_prefix.as_ref());
514514

515515
vec![include, exclude]

0 commit comments

Comments
 (0)