Skip to content

Commit

Permalink
Assure top-level refspecs and tailing '/' for target prefix
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Byron committed Mar 23, 2024
1 parent dbf1b6a commit 9178160
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/cargo/sources/path.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down Expand Up @@ -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));
Expand All @@ -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]
Expand Down

0 comments on commit 9178160

Please sign in to comment.