diff --git a/src/cred.rs b/src/cred.rs index 72d9485e82..2a2c1e9838 100644 --- a/src/cred.rs +++ b/src/cred.rs @@ -263,6 +263,9 @@ impl CredentialHelper { } let global = config.get_string("credential.helper"); self.add_command(global.as_ref().ok().map(|s| &s[..])); + + // add the "fill" command + self.add_command(Some("!git credential fill")); } // Discover `useHttpPath` from `config` @@ -303,7 +306,7 @@ impl CredentialHelper { } else if cmd.contains("/") || cmd.contains("\\") { self.commands.push(cmd.to_string()); } else { - self.commands.push(format!("git credential-{}", cmd)); + self.commands.push(format!("git credential-{} get", cmd)); } } @@ -329,8 +332,11 @@ impl CredentialHelper { let mut password = None; for cmd in &self.commands { let (u, p) = self.execute_cmd(cmd, &username); - if u.is_some() && username.is_none() { - username = u; + #[allow(clippy::collapsible_if)] + if let Some(u) = u { + if !u.is_empty() && username.is_none() { + username = Some(u); + } } if p.is_some() && password.is_none() { password = p; @@ -374,7 +380,7 @@ impl CredentialHelper { // sure it works. let mut c = Command::new("sh"); c.arg("-c") - .arg(&format!("{} get", cmd)) + .arg(cmd) .stdin(Stdio::piped()) .stdout(Stdio::piped()) .stderr(Stdio::piped());