From 0eb98223b893f239c8e4e5e70e1f060e0fde8260 Mon Sep 17 00:00:00 2001 From: Black616Angel Date: Fri, 5 Jan 2024 16:08:28 +0100 Subject: [PATCH 1/3] reposition appended "get" to better suit other commands --- src/cred.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cred.rs b/src/cred.rs index 72d9485e82..449669b25d 100644 --- a/src/cred.rs +++ b/src/cred.rs @@ -303,7 +303,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)); } } @@ -374,7 +374,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()); From 5cf499ace878da1420fb2b74013104ee14ea4318 Mon Sep 17 00:00:00 2001 From: Black616Angel Date: Fri, 5 Jan 2024 16:09:22 +0100 Subject: [PATCH 2/3] adding the command "git credential fill" --- src/cred.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/cred.rs b/src/cred.rs index 449669b25d..9517d2d7ea 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` From 532aa26e9923e956fed6842bef59cdd79acb6229 Mon Sep 17 00:00:00 2001 From: Black616Angel Date: Fri, 5 Jan 2024 16:09:48 +0100 Subject: [PATCH 3/3] ignoring output with empty username --- src/cred.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/cred.rs b/src/cred.rs index 9517d2d7ea..2a2c1e9838 100644 --- a/src/cred.rs +++ b/src/cred.rs @@ -332,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;