Skip to content

Commit 71308d0

Browse files
authored
Merge pull request #402 from hmarr/master
Don't quote absolute path helper commands
2 parents 5d82167 + fa1dfb6 commit 71308d0

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
lines changed

src/cred.rs

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ impl CredentialHelper {
257257
self.commands.push(cmd[1..].to_string());
258258
} else if cmd.starts_with('/') || cmd.starts_with('\\') ||
259259
cmd[1..].starts_with(":\\") {
260-
self.commands.push(format!("\"{}\"", cmd));
260+
self.commands.push(cmd.to_string());
261261
} else {
262262
self.commands.push(format!("git credential-{}", cmd));
263263
}
@@ -522,6 +522,26 @@ echo username=c
522522
.execute().is_none());
523523
}
524524

525+
#[test]
526+
fn credential_helper7() {
527+
let td = TempDir::new("git2-rs").unwrap();
528+
let path = td.path().join("script");
529+
File::create(&path).unwrap().write(br"\
530+
#!/bin/sh
531+
echo username=$1
532+
echo password=$2
533+
").unwrap();
534+
chmod(&path);
535+
let cfg = test_cfg! {
536+
"credential.helper" => &format!("{} a b", path.display())
537+
};
538+
let (u, p) = CredentialHelper::new("https://example.com/foo/bar")
539+
.config(&cfg)
540+
.execute().unwrap();
541+
assert_eq!(u, "a");
542+
assert_eq!(p, "b");
543+
}
544+
525545
#[test]
526546
fn ssh_key_from_memory() {
527547
let cred = Cred::ssh_key_from_memory(

0 commit comments

Comments
 (0)