Skip to content

Commit 45c390a

Browse files
committed
Switch to using gitoxide by default for listing files
1 parent 09d5e96 commit 45c390a

File tree

3 files changed

+40
-12
lines changed

3 files changed

+40
-12
lines changed

src/cargo/core/features.rs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -909,8 +909,6 @@ fn parse_git(it: impl Iterator<Item = impl AsRef<str>>) -> CargoResult<Option<Gi
909909
pub struct GitoxideFeatures {
910910
/// All fetches are done with `gitoxide`, which includes git dependencies as well as the crates index.
911911
pub fetch: bool,
912-
/// Listing of files suitable for packaging with Git support.
913-
pub list_files: bool,
914912
/// Checkout git dependencies using `gitoxide` (submodules are still handled by git2 ATM, and filters
915913
/// like linefeed conversions are unsupported).
916914
pub checkout: bool,
@@ -924,7 +922,6 @@ impl GitoxideFeatures {
924922
fn all() -> Self {
925923
GitoxideFeatures {
926924
fetch: true,
927-
list_files: true,
928925
checkout: true,
929926
internal_use_git2: false,
930927
}
@@ -935,7 +932,6 @@ impl GitoxideFeatures {
935932
fn safe() -> Self {
936933
GitoxideFeatures {
937934
fetch: true,
938-
list_files: true,
939935
checkout: true,
940936
internal_use_git2: false,
941937
}
@@ -948,7 +944,6 @@ fn parse_gitoxide(
948944
let mut out = GitoxideFeatures::default();
949945
let GitoxideFeatures {
950946
fetch,
951-
list_files,
952947
checkout,
953948
internal_use_git2,
954949
} = &mut out;
@@ -957,10 +952,9 @@ fn parse_gitoxide(
957952
match e.as_ref() {
958953
"fetch" => *fetch = true,
959954
"checkout" => *checkout = true,
960-
"list-files" => *list_files = true,
961955
"internal-use-git2" => *internal_use_git2 = true,
962956
_ => {
963-
bail!("unstable 'gitoxide' only takes `fetch`, `list-files` and 'checkout' as valid input, for shallow fetches see `-Zgit=shallow-index,shallow-deps`")
957+
bail!("unstable 'gitoxide' only takes `fetch` and 'checkout' as valid input, for shallow fetches see `-Zgit=shallow-index,shallow-deps`")
964958
}
965959
}
966960
}

src/cargo/sources/path.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -143,13 +143,14 @@ impl<'gctx> PathSource<'gctx> {
143143
let git_repo = if no_include_option {
144144
if self
145145
.gctx
146-
.cli_unstable()
147-
.gitoxide
148-
.map_or(false, |features| features.list_files)
146+
.get_env("__CARGO_GITOXIDE_DISABLE_LIST_FILES")
147+
.ok()
148+
.as_deref()
149+
== Some("1")
149150
{
150-
self.discover_gix_repo(root)?.map(Git2OrGixRepository::Gix)
151-
} else {
152151
self.discover_git_repo(root)?.map(Git2OrGixRepository::Git2)
152+
} else {
153+
self.discover_gix_repo(root)?.map(Git2OrGixRepository::Gix)
153154
}
154155
} else {
155156
None

tests/testsuite/package.rs

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3510,3 +3510,36 @@ Please update the `build` setting in the manifest at `[CWD]/Cargo.toml` and poin
35103510
.with_stderr(&expect_msg)
35113511
.run();
35123512
}
3513+
3514+
#[cargo_test]
3515+
fn symlink_manifest_path() {
3516+
// Test `cargo install --manifest-path` pointing through a symlink.
3517+
if !symlink_supported() {
3518+
return;
3519+
}
3520+
let p = git::new("foo", |p| {
3521+
p.file("Cargo.toml", &basic_manifest("foo", "1.0.0"))
3522+
.file("src/main.rs", "fn main() {}")
3523+
// Triggers discover_git_and_list_files for detecting changed files.
3524+
.file("build.rs", "fn main() {}")
3525+
});
3526+
#[cfg(unix)]
3527+
use std::os::unix::fs::symlink;
3528+
#[cfg(windows)]
3529+
use std::os::windows::fs::symlink_dir as symlink;
3530+
3531+
let foo_symlink = paths::root().join("foo-symlink");
3532+
t!(symlink(p.root(), &foo_symlink));
3533+
3534+
cargo_process("package --no-verify --manifest-path")
3535+
.arg(foo_symlink.join("Cargo.toml"))
3536+
.with_stderr(
3537+
"\
3538+
warning: manifest has no description, license, license-file, documentation, homepage or repository.
3539+
See https://doc.rust-lang.org/cargo/reference/manifest.html#package-metadata for more info.
3540+
[PACKAGING] foo v1.0.0 ([..]foo-symlink)
3541+
[PACKAGED] 5 files[..]
3542+
",
3543+
)
3544+
.run()
3545+
}

0 commit comments

Comments
 (0)