Skip to content

Commit dc21164

Browse files
committed
Merge branch 'nd/connect-ssh-command-config'
A new configuration variable core.sshCommand has been added to specify what value for GIT_SSH_COMMAND to use per repository. * nd/connect-ssh-command-config: connect: read $GIT_SSH_COMMAND from config file
2 parents 2949358 + 3c8ede3 commit dc21164

2 files changed

Lines changed: 21 additions & 1 deletion

File tree

Documentation/config.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -450,6 +450,13 @@ specify that no proxy be used for a given domain pattern.
450450
This is useful for excluding servers inside a firewall from
451451
proxy use, while defaulting to a common proxy for external domains.
452452

453+
core.sshCommand::
454+
If this variable is set, `git fetch` and `git push` will
455+
use the specified command instead of `ssh` when they need to
456+
connect to a remote system. The command is in the same form as
457+
the `GIT_SSH_COMMAND` environment variable and is overridden
458+
when the environment variable is set.
459+
453460
core.ignoreStat::
454461
If true, Git will avoid using lstat() calls to detect if files have
455462
changed by setting the "assume-unchanged" bit for those tracked files

connect.c

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -658,6 +658,19 @@ static enum protocol parse_connect_url(const char *url_orig, char **ret_host,
658658

659659
static struct child_process no_fork = CHILD_PROCESS_INIT;
660660

661+
static const char *get_ssh_command(void)
662+
{
663+
const char *ssh;
664+
665+
if ((ssh = getenv("GIT_SSH_COMMAND")))
666+
return ssh;
667+
668+
if (!git_config_get_string_const("core.sshcommand", &ssh))
669+
return ssh;
670+
671+
return NULL;
672+
}
673+
661674
/*
662675
* This returns a dummy child_process if the transport protocol does not
663676
* need fork(2), or a struct child_process object if it does. Once done,
@@ -758,7 +771,7 @@ struct child_process *git_connect(int fd[2], const char *url,
758771
return NULL;
759772
}
760773

761-
ssh = getenv("GIT_SSH_COMMAND");
774+
ssh = get_ssh_command();
762775
if (!ssh) {
763776
const char *base;
764777
char *ssh_dup;

0 commit comments

Comments
 (0)