Skip to content

Commit c776e8d

Browse files
committed
Fix CredentialHelper::add_command
Fixes #1136
1 parent adbbbf4 commit c776e8d

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

Diff for: src/cred.rs

+7-1
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,7 @@ 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));
@@ -481,6 +481,12 @@ impl CredentialHelper {
481481
}
482482
}
483483

484+
fn is_absolute_path(path: &str) -> bool {
485+
path.starts_with('/')
486+
|| path.starts_with('\\')
487+
|| cfg!(windows) && path.chars().nth(1).is_some_and(|x| x == ':')
488+
}
489+
484490
#[cfg(test)]
485491
mod test {
486492
use std::env;

0 commit comments

Comments
 (0)