Skip to content

Commit 6a4f3a9

Browse files
committed
connect: rename tortoiseplink and putty variables
One of these two may have originally been named after "what exact SSH implementation do we have?" so that we can tweak the command line options for that exact implementation. But "putty=1" no longer means "We are using the plink SSH implementation that comes with PuTTY" these days. It is set when we guess that either PuTTY plink or Tortoiseplink is in use. Rename them after what effect is desired. The current 'putty' option is about using "-P <port>" when OpenSSH would use "-p <port>", so rename it to 'port_option' whose value is either 'p' or 'P". The other one is about passing an extra command line option "-batch", so rename it to 'needs_batch'. [jes: wrapped overly-long line] Signed-off-by: Junio C Hamano <[email protected]> Signed-off-by: Johannes Schindelin <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent e9d9a8a commit 6a4f3a9

File tree

1 file changed

+13
-10
lines changed

1 file changed

+13
-10
lines changed

connect.c

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -769,7 +769,8 @@ struct child_process *git_connect(int fd[2], const char *url,
769769
conn->in = conn->out = -1;
770770
if (protocol == PROTO_SSH) {
771771
const char *ssh;
772-
int putty = 0, tortoiseplink = 0;
772+
int needs_batch = 0;
773+
int port_option = 'p';
773774
char *ssh_host = hostandport;
774775
const char *port = NULL;
775776
char *ssh_argv0 = NULL;
@@ -819,12 +820,14 @@ struct child_process *git_connect(int fd[2], const char *url,
819820
if (ssh_argv0) {
820821
const char *base = basename(ssh_argv0);
821822

822-
tortoiseplink = !strcasecmp(base, "tortoiseplink") ||
823-
!strcasecmp(base, "tortoiseplink.exe");
824-
putty = tortoiseplink ||
825-
!strcasecmp(base, "plink") ||
826-
!strcasecmp(base, "plink.exe");
827-
823+
if (!strcasecmp(base, "tortoiseplink") ||
824+
!strcasecmp(base, "tortoiseplink.exe")) {
825+
port_option = 'P';
826+
needs_batch = 1;
827+
} else if (!strcasecmp(base, "plink") ||
828+
!strcasecmp(base, "plink.exe")) {
829+
port_option = 'P';
830+
}
828831
free(ssh_argv0);
829832
}
830833

@@ -833,11 +836,11 @@ struct child_process *git_connect(int fd[2], const char *url,
833836
argv_array_push(&conn->args, "-4");
834837
else if (flags & CONNECT_IPV6)
835838
argv_array_push(&conn->args, "-6");
836-
if (tortoiseplink)
839+
if (needs_batch)
837840
argv_array_push(&conn->args, "-batch");
838841
if (port) {
839-
/* P is for PuTTY, p is for OpenSSH */
840-
argv_array_push(&conn->args, putty ? "-P" : "-p");
842+
argv_array_pushf(&conn->args,
843+
"-%c", port_option);
841844
argv_array_push(&conn->args, port);
842845
}
843846
argv_array_push(&conn->args, ssh_host);

0 commit comments

Comments
 (0)