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 <gitster@pobox.com> Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Junio C Hamano committed Jan 26, 2017 at 15:51 UTC 6a4f3a9edc25ab091bbe07b537456019fd20e958
1 file changed +13 -10
connect.c
+13 -10
@@ -769,7 +769,8 @@ struct child_process *git_connect(int fd[2], const char *url,
769 conn->in = conn->out = -1;
770 if (protocol == PROTO_SSH) {
771 const char *ssh;
772 - int putty = 0, tortoiseplink = 0;
772 + int needs_batch = 0;
773 + int port_option = 'p';
774 char *ssh_host = hostandport;
775 const char *port = NULL;
776 char *ssh_argv0 = NULL;
@@ -819,12 +820,14 @@ struct child_process *git_connect(int fd[2], const char *url,
820 if (ssh_argv0) {
821 const char *base = basename(ssh_argv0);
822
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 + }
831 free(ssh_argv0);
832 }
833
@@ -833,11 +836,11 @@ struct child_process *git_connect(int fd[2], const char *url,
836 argv_array_push(&conn->args, "-4");
837 else if (flags & CONNECT_IPV6)
838 argv_array_push(&conn->args, "-6");
836 - if (tortoiseplink)
839 + if (needs_batch)
840 argv_array_push(&conn->args, "-batch");
841 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);
844 argv_array_push(&conn->args, port);
845 }
846 argv_array_push(&conn->args, ssh_host);