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
12 changes: 12 additions & 0 deletions src/sources/git/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1263,6 +1263,8 @@ https://doc.rust-lang.org/cargo/reference/config.html#netgit-fetch-with-cli"
let mut cmd = ProcessBuilder::new("git");
// Avoid potential for unused work that may also hang (#15775)
cmd.arg("-c").arg("core.fsmonitor=false");
// Avoid warnings with `--no-show-forced-updates`
cmd.arg("-c").arg("advice.fetchShowForcedUpdates=false");

cmd.arg("fetch");
if tags {
Expand Down Expand Up @@ -1304,6 +1306,16 @@ https://doc.rust-lang.org/cargo/reference/config.html#netgit-fetch-with-cli"
cmd.arg("--quiet");
}

let min_no_show_forced_update = GitVersion {
major: 2,
minor: 23,
patch: 0,
};
if min_no_show_forced_update <= git_version {
// skip unneeded expensive calculations
cmd.arg("--no-show-forced-updates");
}

cmd.arg("--force") // handle force pushes
.arg("--update-head-ok") // see discussion in #2078
.arg("--recurse-submodules=no") // we handle this, incompatible with `--porcelain`
Expand Down
20 changes: 10 additions & 10 deletions tests/testsuite/git.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3171,7 +3171,7 @@ fn use_the_cli() {

let stderr = str![[r#"
[UPDATING] git repository `[ROOTURL]/dep1`
[RUNNING] `git -c core.fsmonitor=false fetch --no-tags --verbose --force --update-head-ok [..][ROOTURL]/dep1[..] [..]+HEAD:refs/remotes/origin/HEAD[..]`
[RUNNING] `git[..] fetch --no-tags --verbose[..] --force --update-head-ok [..][ROOTURL]/dep1[..] [..]+HEAD:refs/remotes/origin/HEAD[..]`
From [ROOTURL]/dep1
* [new ref] [..] -> origin/HEAD[..]
[LOCKING] 1 package to highest compatible version
Expand Down Expand Up @@ -3455,7 +3455,7 @@ Caused by:
failed to clone into: [ROOT]/home/.cargo/git/db/missing-[HASH]

Caused by:
process didn't exit successfully: `git -c core.fsmonitor=false fetch [..]` ([EXIT_STATUS]: 128)
process didn't exit successfully: `git[..] fetch [..]` ([EXIT_STATUS]: 128)

[HELP] re-try with `net.git-fetch-with-cli = false` to see if it resolves the problem
https://doc.rust-lang.org/cargo/reference/config.html#netgit-fetch-with-cli
Expand Down Expand Up @@ -3612,17 +3612,17 @@ fn git_cli_arg_injection_via_branch() {
.with_stderr_data(str![[r#"
[UPDATING] git repository `[ROOTURL]/dep1`
fatal: couldn't find remote ref refs/heads/-u./payload
[WARNING] spurious network error (3 tries remaining): process didn't exit successfully: `git -c core.fsmonitor=false fetch [..]` ([EXIT_STATUS]: 128)
[WARNING] spurious network error (3 tries remaining): process didn't exit successfully: `git[..] fetch [..]` ([EXIT_STATUS]: 128)

[HELP] re-try with `net.git-fetch-with-cli = false` to see if it resolves the problem
https://doc.rust-lang.org/cargo/reference/config.html#netgit-fetch-with-cli
fatal: couldn't find remote ref refs/heads/-u./payload
[WARNING] spurious network error (2 tries remaining): process didn't exit successfully: `git -c core.fsmonitor=false fetch [..]` ([EXIT_STATUS]: 128)
[WARNING] spurious network error (2 tries remaining): process didn't exit successfully: `git[..] fetch [..]` ([EXIT_STATUS]: 128)

[HELP] re-try with `net.git-fetch-with-cli = false` to see if it resolves the problem
https://doc.rust-lang.org/cargo/reference/config.html#netgit-fetch-with-cli
fatal: couldn't find remote ref refs/heads/-u./payload
[WARNING] spurious network error (1 try remaining): process didn't exit successfully: `git -c core.fsmonitor=false fetch [..]` ([EXIT_STATUS]: 128)
[WARNING] spurious network error (1 try remaining): process didn't exit successfully: `git[..] fetch [..]` ([EXIT_STATUS]: 128)

[HELP] re-try with `net.git-fetch-with-cli = false` to see if it resolves the problem
https://doc.rust-lang.org/cargo/reference/config.html#netgit-fetch-with-cli
Expand All @@ -3639,7 +3639,7 @@ Caused by:
failed to clone into: [ROOT]/home/.cargo/git/db/dep1-[HASH]

Caused by:
process didn't exit successfully: `git -c core.fsmonitor=false fetch [..]` ([EXIT_STATUS]: 128)
process didn't exit successfully: `git[..] fetch [..]` ([EXIT_STATUS]: 128)

[HELP] re-try with `net.git-fetch-with-cli = false` to see if it resolves the problem
https://doc.rust-lang.org/cargo/reference/config.html#netgit-fetch-with-cli
Expand Down Expand Up @@ -4625,17 +4625,17 @@ fn github_fastpath_error_message() {
.with_stderr_data(str![[r#"
[UPDATING] git repository `https://github.com/rust-lang/bitflags.git`
fatal: remote [ERROR] upload-pack: not our ref 11111b376b93484341c68fbca3ca110ae5cd2790
[WARNING] spurious network error (3 tries remaining): process didn't exit successfully: `git -c core.fsmonitor=false fetch --no-tags --quiet --force --update-head-ok [..]
[WARNING] spurious network error (3 tries remaining): process didn't exit successfully: `git [..]

[HELP] re-try with `net.git-fetch-with-cli = false` to see if it resolves the problem
https://doc.rust-lang.org/cargo/reference/config.html#netgit-fetch-with-cli
fatal: remote [ERROR] upload-pack: not our ref 11111b376b93484341c68fbca3ca110ae5cd2790
[WARNING] spurious network error (2 tries remaining): process didn't exit successfully: `git -c core.fsmonitor=false fetch --no-tags --quiet --force --update-head-ok [..]
[WARNING] spurious network error (2 tries remaining): process didn't exit successfully: `git[..]

[HELP] re-try with `net.git-fetch-with-cli = false` to see if it resolves the problem
https://doc.rust-lang.org/cargo/reference/config.html#netgit-fetch-with-cli
fatal: remote [ERROR] upload-pack: not our ref 11111b376b93484341c68fbca3ca110ae5cd2790
[WARNING] spurious network error (1 try remaining): process didn't exit successfully: `git -c core.fsmonitor=false fetch --no-tags --quiet --force --update-head-ok [..]
[WARNING] spurious network error (1 try remaining): process didn't exit successfully: `git[..]

[HELP] re-try with `net.git-fetch-with-cli = false` to see if it resolves the problem
https://doc.rust-lang.org/cargo/reference/config.html#netgit-fetch-with-cli
Expand All @@ -4655,7 +4655,7 @@ Caused by:
revision 11111b376b93484341c68fbca3ca110ae5cd2790 not found

Caused by:
process didn't exit successfully: `git -c core.fsmonitor=false fetch --no-tags --quiet --force --update-head-ok [..]
process didn't exit successfully: `git[..] fetch --no-tags --quiet[..] --force --update-head-ok [..]

[HELP] re-try with `net.git-fetch-with-cli = false` to see if it resolves the problem
https://doc.rust-lang.org/cargo/reference/config.html#netgit-fetch-with-cli
Expand Down