зеркало из https://github.com/microsoft/git.git
connect: Add the envvar GIT_SSH_VARIANT and ssh.variant config
This environment variable and configuration value allow to override the autodetection of plink/tortoiseplink in case that Git gets it wrong. [jes: wrapped overly-long lines, factored out and changed get_ssh_variant() to handle_ssh_variant() to accomodate the change from the putty/tortoiseplink variables to port_option/needs_batch, adjusted the documentation, free()d value obtained from the config.] Signed-off-by: Segev Finer <segev208@gmail.com> Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Родитель
e2824e47e7
Коммит
dd33e07766
|
@ -1949,6 +1949,17 @@ Environment variable settings always override any matches. The URLs that are
|
|||
matched against are those given directly to Git commands. This means any URLs
|
||||
visited as a result of a redirection do not participate in matching.
|
||||
|
||||
ssh.variant::
|
||||
Depending on the value of the environment variables `GIT_SSH` or
|
||||
`GIT_SSH_COMMAND`, or the config setting `core.sshCommand`, Git
|
||||
auto-detects whether to adjust its command-line parameters for use
|
||||
with plink or tortoiseplink, as opposed to the default (OpenSSH).
|
||||
+
|
||||
The config variable `ssh.variant` can be set to override this auto-detection;
|
||||
valid values are `ssh`, `plink`, `putty` or `tortoiseplink`. Any other value
|
||||
will be treated as normal ssh. This setting can be overridden via the
|
||||
environment variable `GIT_SSH_VARIANT`.
|
||||
|
||||
i18n.commitEncoding::
|
||||
Character encoding the commit messages are stored in; Git itself
|
||||
does not care per se, but this information is necessary e.g. when
|
||||
|
|
|
@ -1020,6 +1020,12 @@ Usually it is easier to configure any desired options through your
|
|||
personal `.ssh/config` file. Please consult your ssh documentation
|
||||
for further details.
|
||||
|
||||
`GIT_SSH_VARIANT`::
|
||||
If this environment variable is set, it overrides Git's autodetection
|
||||
whether `GIT_SSH`/`GIT_SSH_COMMAND`/`core.sshCommand` refer to OpenSSH,
|
||||
plink or tortoiseplink. This variable overrides the config setting
|
||||
`ssh.variant` that serves the same purpose.
|
||||
|
||||
`GIT_ASKPASS`::
|
||||
If this environment variable is set, then Git commands which need to
|
||||
acquire passwords or passphrases (e.g. for HTTP or IMAP authentication)
|
||||
|
|
11
connect.c
11
connect.c
|
@ -694,10 +694,14 @@ static const char *get_ssh_command(void)
|
|||
static int handle_ssh_variant(const char *ssh_command, int is_cmdline,
|
||||
int *port_option, int *needs_batch)
|
||||
{
|
||||
const char *variant;
|
||||
const char *variant = getenv("GIT_SSH_VARIANT");
|
||||
char *p = NULL;
|
||||
|
||||
if (!is_cmdline) {
|
||||
if (variant)
|
||||
; /* okay, fall through */
|
||||
else if (!git_config_get_string("ssh.variant", &p))
|
||||
variant = p;
|
||||
else if (!is_cmdline) {
|
||||
p = xstrdup(ssh_command);
|
||||
variant = basename(p);
|
||||
} else {
|
||||
|
@ -717,7 +721,8 @@ static int handle_ssh_variant(const char *ssh_command, int is_cmdline,
|
|||
}
|
||||
|
||||
if (!strcasecmp(variant, "plink") ||
|
||||
!strcasecmp(variant, "plink.exe"))
|
||||
!strcasecmp(variant, "plink.exe") ||
|
||||
!strcasecmp(variant, "putty"))
|
||||
*port_option = 'P';
|
||||
else if (!strcasecmp(variant, "tortoiseplink") ||
|
||||
!strcasecmp(variant, "tortoiseplink.exe")) {
|
||||
|
|
|
@ -401,6 +401,32 @@ test_expect_success 'single quoted plink.exe in GIT_SSH_COMMAND' '
|
|||
expect_ssh "-v -P 123" myhost src
|
||||
'
|
||||
|
||||
test_expect_success 'GIT_SSH_VARIANT overrides plink detection' '
|
||||
copy_ssh_wrapper_as "$TRASH_DIRECTORY/plink" &&
|
||||
GIT_SSH_VARIANT=ssh \
|
||||
git clone "[myhost:123]:src" ssh-bracket-clone-variant-1 &&
|
||||
expect_ssh "-p 123" myhost src
|
||||
'
|
||||
|
||||
test_expect_success 'ssh.variant overrides plink detection' '
|
||||
copy_ssh_wrapper_as "$TRASH_DIRECTORY/plink" &&
|
||||
git -c ssh.variant=ssh \
|
||||
clone "[myhost:123]:src" ssh-bracket-clone-variant-2 &&
|
||||
expect_ssh "-p 123" myhost src
|
||||
'
|
||||
|
||||
test_expect_success 'GIT_SSH_VARIANT overrides plink detection to plink' '
|
||||
GIT_SSH_VARIANT=plink \
|
||||
git clone "[myhost:123]:src" ssh-bracket-clone-variant-3 &&
|
||||
expect_ssh "-P 123" myhost src
|
||||
'
|
||||
|
||||
test_expect_success 'GIT_SSH_VARIANT overrides plink to tortoiseplink' '
|
||||
GIT_SSH_VARIANT=tortoiseplink \
|
||||
git clone "[myhost:123]:src" ssh-bracket-clone-variant-4 &&
|
||||
expect_ssh "-batch -P 123" myhost src
|
||||
'
|
||||
|
||||
# Reset the GIT_SSH environment variable for clone tests.
|
||||
setup_ssh_wrapper
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче