Skip to content

Commit 08d3fcc

Browse files
committed
Don't retry git credential helpers
If the git credential helper returns invalid credentials, we currently get stuck in an infinite retry loop by calling the credentials callback over and over, each time returning the same invalid credentials. This change means we only invoke the credential helper once.
1 parent 55895e7 commit 08d3fcc

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/cargo/sources/git/utils.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -451,6 +451,7 @@ where
451451
let mut ssh_agent_attempts = Vec::new();
452452
let mut any_attempts = false;
453453
let mut tried_sshkey = false;
454+
let mut tried_cred_helper = false;
454455

455456
let mut res = f(&mut |url, username, allowed| {
456457
any_attempts = true;
@@ -503,7 +504,8 @@ where
503504
// but we currently don't! Right now the only way we support fetching a
504505
// plaintext password is through the `credential.helper` support, so
505506
// fetch that here.
506-
if allowed.contains(git2::CredentialType::USER_PASS_PLAINTEXT) {
507+
if allowed.contains(git2::CredentialType::USER_PASS_PLAINTEXT) && !tried_cred_helper {
508+
tried_cred_helper = true;
507509
let r = git2::Cred::credential_helper(cfg, url, username);
508510
cred_helper_bad = Some(r.is_err());
509511
return r;

0 commit comments

Comments
 (0)