Skip to content

Commit ff2eff3

Browse files
authored
Fix CredentialHelper::add_command
Fixes #1136
1 parent d1ae3b6 commit ff2eff3

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/cred.rs

+7-1
Original file line numberDiff line numberDiff line change
@@ -299,13 +299,19 @@ impl CredentialHelper {
299299

300300
if cmd.starts_with('!') {
301301
self.commands.push(cmd[1..].to_string());
302-
} else if cmd.contains("/") || cmd.contains("\\") {
302+
} else if is_absolute_path(cmd) {
303303
self.commands.push(cmd.to_string());
304304
} else {
305305
self.commands.push(format!("git credential-{}", cmd));
306306
}
307307
}
308308

309+
fn is_absolute_path(path: &str) -> bool {
310+
path.starts_with('/')
311+
|| path.starts_with('\\')
312+
|| cfg!(windows) && path.chars().nth(1).is_some_and(|x| x == ':')
313+
}
314+
309315
fn exact_key(&self, name: &str) -> String {
310316
format!("credential.{}.{}", self.url, name)
311317
}

0 commit comments

Comments
 (0)