Skip to content

Commit

Permalink
feat: trace credential helper invocations. (GitoxideLabs#1103)
Browse files Browse the repository at this point in the history
This should make it easier to understand what's going on in case
something isn't working as expected.
  • Loading branch information
Byron committed Nov 11, 2023
1 parent 55729a5 commit bc44497
Show file tree
Hide file tree
Showing 8 changed files with 18 additions and 13 deletions.
2 changes: 2 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions gix-command/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ include = ["src/lib.rs", "LICENSE-*"]
doctest = false

[dependencies]
gix-trace = { version = "^0.1.3", path = "../gix-trace" }

bstr = { version = "1.5.0", default-features = false, features = ["std"] }

[dev-dependencies]
Expand Down
4 changes: 3 additions & 1 deletion gix-command/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,9 @@ mod prepare {
impl Prepare {
/// Spawn the command as configured.
pub fn spawn(self) -> std::io::Result<std::process::Child> {
Command::from(self).spawn()
let mut cmd = Command::from(self);
gix_trace::debug!(cmd = ?cmd);
cmd.spawn()
}
}

Expand Down
1 change: 1 addition & 0 deletions gix-credentials/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ gix-path = { version = "^0.10.0", path = "../gix-path" }
gix-command = { version = "^0.2.10", path = "../gix-command" }
gix-config-value = { version = "^0.14.0", path = "../gix-config-value" }
gix-prompt = { version = "^0.7.0", path = "../gix-prompt" }
gix-trace = { version = "^0.1.3", path = "../gix-trace" }

thiserror = "1.0.32"
serde = { version = "1.0.114", optional = true, default-features = false, features = ["derive"] }
Expand Down
1 change: 1 addition & 0 deletions gix-credentials/src/program/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ impl Program {
Stdio::null()
})
.stderr(if self.stderr { Stdio::inherit() } else { Stdio::null() });
gix_trace::debug!(cmd = ?cmd, "launching credential helper");
let mut child = cmd.spawn()?;
let stdin = child.stdin.take().expect("stdin to be configured");
let stdout = child.stdout.take();
Expand Down
1 change: 1 addition & 0 deletions gix-path/src/env/git.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ pub(crate) fn install_config_path() -> Option<&'static BStr> {
cmd.args(["config", "-l", "--show-origin"])
.stdin(Stdio::null())
.stderr(Stdio::null());
gix_trace::debug!(cmd = ?cmd, "invoking git for installation config path");
first_file_from_config_with_origin(cmd.output().ok()?.stdout.as_slice().into()).map(ToOwned::to_owned)
});
PATH.as_ref().map(AsRef::as_ref)
Expand Down
10 changes: 4 additions & 6 deletions gix-path/src/env/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,12 +74,10 @@ pub fn system_prefix() -> Option<&'static Path> {
}
}

let path = std::process::Command::new("git.exe")
.arg("--exec-path")
.stderr(std::process::Stdio::null())
.output()
.ok()?
.stdout;
let mut cmd = std::process::Command::new("git.exe");
cmd.arg("--exec-path").stderr(std::process::Stdio::null());
gix_trace::debug!(cmd = ?cmd, "invoking git to get system prefix/exec path");
let path = cmd.output().ok()?.stdout;
let path = BString::new(path)
.trim_with(|b| b.is_ascii_whitespace())
.to_path()
Expand Down
10 changes: 4 additions & 6 deletions gix-transport/src/client/blocking_io/ssh/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ pub fn connect(
let ssh_cmd = options.ssh_command();
let mut kind = options.kind.unwrap_or_else(|| ProgramKind::from(ssh_cmd));
if options.kind.is_none() && kind == ProgramKind::Simple {
kind = if std::process::Command::from(
let mut cmd = std::process::Command::from(
gix_command::prepare(ssh_cmd)
.stderr(Stdio::null())
.stdout(Stdio::null())
Expand All @@ -117,11 +117,9 @@ pub fn connect(
.arg(url.host_argument_safe().ok_or_else(|| Error::AmbiguousHostName {
host: url.host().expect("set in ssh urls").into(),
})?),
)
.status()
.ok()
.map_or(false, |status| status.success())
{
);
gix_features::trace::debug!(cmd = ?cmd, "invoking `ssh` for feature check");
kind = if cmd.status().ok().map_or(false, |status| status.success()) {
ProgramKind::Ssh
} else {
ProgramKind::Simple
Expand Down

0 comments on commit bc44497

Please sign in to comment.