Skip to content

Commit bc44497

Browse files
committed
feat: trace credential helper invocations. (#1103)
This should make it easier to understand what's going on in case something isn't working as expected.
1 parent 55729a5 commit bc44497

File tree

8 files changed

+18
-13
lines changed

8 files changed

+18
-13
lines changed

Cargo.lock

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

gix-command/Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ include = ["src/lib.rs", "LICENSE-*"]
1313
doctest = false
1414

1515
[dependencies]
16+
gix-trace = { version = "^0.1.3", path = "../gix-trace" }
17+
1618
bstr = { version = "1.5.0", default-features = false, features = ["std"] }
1719

1820
[dev-dependencies]

gix-command/src/lib.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,9 @@ mod prepare {
9393
impl Prepare {
9494
/// Spawn the command as configured.
9595
pub fn spawn(self) -> std::io::Result<std::process::Child> {
96-
Command::from(self).spawn()
96+
let mut cmd = Command::from(self);
97+
gix_trace::debug!(cmd = ?cmd);
98+
cmd.spawn()
9799
}
98100
}
99101

gix-credentials/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ gix-path = { version = "^0.10.0", path = "../gix-path" }
2323
gix-command = { version = "^0.2.10", path = "../gix-command" }
2424
gix-config-value = { version = "^0.14.0", path = "../gix-config-value" }
2525
gix-prompt = { version = "^0.7.0", path = "../gix-prompt" }
26+
gix-trace = { version = "^0.1.3", path = "../gix-trace" }
2627

2728
thiserror = "1.0.32"
2829
serde = { version = "1.0.114", optional = true, default-features = false, features = ["derive"] }

gix-credentials/src/program/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ impl Program {
106106
Stdio::null()
107107
})
108108
.stderr(if self.stderr { Stdio::inherit() } else { Stdio::null() });
109+
gix_trace::debug!(cmd = ?cmd, "launching credential helper");
109110
let mut child = cmd.spawn()?;
110111
let stdin = child.stdin.take().expect("stdin to be configured");
111112
let stdout = child.stdout.take();

gix-path/src/env/git.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ pub(crate) fn install_config_path() -> Option<&'static BStr> {
2222
cmd.args(["config", "-l", "--show-origin"])
2323
.stdin(Stdio::null())
2424
.stderr(Stdio::null());
25+
gix_trace::debug!(cmd = ?cmd, "invoking git for installation config path");
2526
first_file_from_config_with_origin(cmd.output().ok()?.stdout.as_slice().into()).map(ToOwned::to_owned)
2627
});
2728
PATH.as_ref().map(AsRef::as_ref)

gix-path/src/env/mod.rs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -74,12 +74,10 @@ pub fn system_prefix() -> Option<&'static Path> {
7474
}
7575
}
7676

77-
let path = std::process::Command::new("git.exe")
78-
.arg("--exec-path")
79-
.stderr(std::process::Stdio::null())
80-
.output()
81-
.ok()?
82-
.stdout;
77+
let mut cmd = std::process::Command::new("git.exe");
78+
cmd.arg("--exec-path").stderr(std::process::Stdio::null());
79+
gix_trace::debug!(cmd = ?cmd, "invoking git to get system prefix/exec path");
80+
let path = cmd.output().ok()?.stdout;
8381
let path = BString::new(path)
8482
.trim_with(|b| b.is_ascii_whitespace())
8583
.to_path()

gix-transport/src/client/blocking_io/ssh/mod.rs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ pub fn connect(
107107
let ssh_cmd = options.ssh_command();
108108
let mut kind = options.kind.unwrap_or_else(|| ProgramKind::from(ssh_cmd));
109109
if options.kind.is_none() && kind == ProgramKind::Simple {
110-
kind = if std::process::Command::from(
110+
let mut cmd = std::process::Command::from(
111111
gix_command::prepare(ssh_cmd)
112112
.stderr(Stdio::null())
113113
.stdout(Stdio::null())
@@ -117,11 +117,9 @@ pub fn connect(
117117
.arg(url.host_argument_safe().ok_or_else(|| Error::AmbiguousHostName {
118118
host: url.host().expect("set in ssh urls").into(),
119119
})?),
120-
)
121-
.status()
122-
.ok()
123-
.map_or(false, |status| status.success())
124-
{
120+
);
121+
gix_features::trace::debug!(cmd = ?cmd, "invoking `ssh` for feature check");
122+
kind = if cmd.status().ok().map_or(false, |status| status.success()) {
125123
ProgramKind::Ssh
126124
} else {
127125
ProgramKind::Simple

0 commit comments

Comments
 (0)