Skip to main content

git_cmd_safe

Function git_cmd_safe 

Source
pub fn git_cmd_safe(
    url: Option<&str>,
    ssh_policy: Option<SshHostKeyPolicy>,
) -> Command
Expand description

Prepare a git CLI command with SSH hang protection.

Sets GIT_TERMINAL_PROMPT=0 to prevent interactive prompts and, for SSH URLs, sets GIT_SSH_COMMAND with BatchMode=yes and configurable StrictHostKeyChecking to prevent hangs in non-interactive contexts (piped install scripts, daemons).

The ssh_policy parameter controls the StrictHostKeyChecking value:

  • None uses the default (accept-new)
  • Some(policy) uses the specified policy