Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions src/cargo/sources/git/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1030,8 +1030,9 @@ pub fn fetch(
}
}

debug!("doing a fetch for {remote_url}");
let result = if let Some(true) = gctx.net_config()?.git_fetch_with_cli {
fetch_with_cli(repo, remote_url, &refspecs, tags, gctx)
fetch_with_cli(repo, remote_url, &refspecs, tags, shallow, gctx)
} else if gctx.cli_unstable().gitoxide.map_or(false, |git| git.fetch) {
fetch_with_gitoxide(repo, remote_url, refspecs, tags, shallow, gctx)
} else {
Expand Down Expand Up @@ -1075,15 +1076,22 @@ fn fetch_with_cli(
url: &str,
refspecs: &[String],
tags: bool,
shallow: gix::remote::fetch::Shallow,
gctx: &GlobalContext,
) -> CargoResult<()> {
debug!(target: "git-fetch", backend = "git-cli");

let mut cmd = ProcessBuilder::new("git");
cmd.arg("fetch");
if tags {
cmd.arg("--tags");
} else {
cmd.arg("--no-tags");
}
if let gix::remote::fetch::Shallow::DepthAtRemote(depth) = shallow {
let depth = 0i32.saturating_add_unsigned(depth.get());
cmd.arg(format!("--depth={depth}"));
}
match gctx.shell().verbosity() {
Verbosity::Normal => {}
Verbosity::Verbose => {
Expand Down Expand Up @@ -1126,6 +1134,8 @@ fn fetch_with_gitoxide(
shallow: gix::remote::fetch::Shallow,
gctx: &GlobalContext,
) -> CargoResult<()> {
debug!(target: "git-fetch", backend = "gitoxide");

let git2_repo = repo;
let config_overrides = cargo_config_to_gitoxide_overrides(gctx)?;
let repo_reinitialized = AtomicBool::default();
Expand Down Expand Up @@ -1234,7 +1244,8 @@ fn fetch_with_libgit2(
shallow: gix::remote::fetch::Shallow,
gctx: &GlobalContext,
) -> CargoResult<()> {
debug!("doing a fetch for {remote_url}");
debug!(target: "git-fetch", backend = "libgit2");

let git_config = git2::Config::open_default()?;
with_fetch_options(&git_config, remote_url, gctx, &mut |mut opts| {
if tags {
Expand Down
Loading