Skip to content

Commit bef6464

Browse files
committed
Add debug logging for failed credential helpers
1 parent 374850f commit bef6464

File tree

3 files changed

+16
-2
lines changed

3 files changed

+16
-2
lines changed

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ appveyor = { repository = "alexcrichton/git2-rs" }
2424
url = "1.0"
2525
bitflags = "1.0"
2626
libc = "0.2"
27+
log = "0.4"
2728
libgit2-sys = { path = "libgit2-sys", version = "0.7.0" }
2829

2930
[target."cfg(all(unix, not(target_os = \"macos\")))".dependencies]

src/cred.rs

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,13 @@ impl CredentialHelper {
287287
fn execute_cmd(&self, cmd: &str, username: &Option<String>)
288288
-> (Option<String>, Option<String>) {
289289
macro_rules! my_try( ($e:expr) => (
290-
match $e { Ok(e) => e, Err(..) => return (None, None) }
290+
match $e {
291+
Ok(e) => e,
292+
Err(e) => {
293+
debug!("{} failed with {}", stringify!($e), e);
294+
return (None, None)
295+
}
296+
}
291297
) );
292298

293299
let mut p = my_try!(Command::new("sh").arg("-c")
@@ -311,7 +317,13 @@ impl CredentialHelper {
311317
}
312318
}
313319
let output = my_try!(p.wait_with_output());
314-
if !output.status.success() { return (None, None) }
320+
if !output.status.success() {
321+
debug!("credential helper failed: {}\nstdout ---\n{}\nstdout ---\n{}",
322+
output.status,
323+
String::from_utf8_lossy(&output.stdout),
324+
String::from_utf8_lossy(&output.stderr));
325+
return (None, None)
326+
}
315327
self.parse_output(output.stdout)
316328
}
317329

src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ extern crate libc;
7272
extern crate url;
7373
extern crate libgit2_sys as raw;
7474
#[macro_use] extern crate bitflags;
75+
#[macro_use] extern crate log;
7576
#[cfg(test)] extern crate tempdir;
7677

7778
use std::ffi::{CStr, CString};

0 commit comments

Comments
 (0)