Skip to content

Commit

Permalink
Use Url::host_as_argument() in ssh::connect()
Browse files Browse the repository at this point in the history
Instead of `Url::host_argument_safe()`.

This also removes the comment about how the username should be
handled if added, mostly because I didn't really need to add that
comment.
  • Loading branch information
EliahKagan committed Apr 12, 2024
1 parent 2911623 commit 28a5018
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions gix-transport/src/client/blocking_io/ssh/mod.rs
@@ -1,5 +1,7 @@
use std::process::Stdio;

use gix_url::ArgumentSafety::*;

use crate::{client::blocking_io, Protocol};

/// The error used in [`connect()`].
Expand Down Expand Up @@ -118,11 +120,11 @@ pub fn connect(
.stdin(Stdio::null())
.with_shell()
.arg("-G")
// Username affects the stdout from `ssh -G` but may not affect the status. But if
// we end up needing it, it can be added here, with a user_argument_safe() check.
.arg(url.host_argument_safe().ok_or_else(|| Error::AmbiguousHostName {
host: url.host().expect("set in ssh urls").into(),
})?),
.arg(match url.host_as_argument() {
Usable(host) => host,
Dangerous(host) => Err(Error::AmbiguousHostName { host: host.into() })?,
Absent => panic!("BUG: host should always be present in SSH URLs"),
}),
);
gix_features::trace::debug!(cmd = ?cmd, "invoking `ssh` for feature check");
kind = if cmd.status().ok().map_or(false, |status| status.success()) {
Expand Down

0 comments on commit 28a5018

Please sign in to comment.