From: Junio C Hamano Date: Mon, 27 Apr 2015 19:23:53 +0000 (-0700) Subject: Merge branch 'tb/connect-ipv6-parse-fix' into maint X-Git-Tag: v2.3.7~1 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/ad34ad614da30387c82a54c7087705050b4de441?ds=inline;hp=-c Merge branch 'tb/connect-ipv6-parse-fix' into maint An earlier update to the parser that disects a URL broke an address, followed by a colon, followed by an empty string (instead of the port number), e.g. ssh://example.com:/path/to/repo. * tb/connect-ipv6-parse-fix: connect.c: ignore extra colon after hostname --- ad34ad614da30387c82a54c7087705050b4de441 diff --combined connect.c index ce0e121423,dc31b795e7..14c924b030 --- a/connect.c +++ b/connect.c @@@ -93,7 -93,7 +93,7 @@@ static void annotate_refs_with_symref_i parse_one_symref_info(&symref, val, len); feature_list = val + 1; } - sort_string_list(&symref); + string_list_sort(&symref); for (; ref; ref = ref->next) { struct string_list_item *item; @@@ -157,7 -157,8 +157,7 @@@ struct ref **get_remote_heads(int in, c server_capabilities = xstrdup(name + name_len + 1); } - if (extra_have && - name_len == 5 && !memcmp(".have", name, 5)) { + if (extra_have && !strcmp(name, ".have")) { sha1_array_append(extra_have, old_sha1); continue; } @@@ -310,6 -311,8 +310,8 @@@ static void get_host_and_port(char **ho if (end != colon + 1 && *end == '\0' && 0 <= portnr && portnr < 65536) { *colon = 0; *port = colon + 1; + } else if (!colon[1]) { + *colon = 0; } } } @@@ -681,20 -684,10 +683,20 @@@ struct child_process *git_connect(int f printf("Diag: path=%s\n", path ? path : "NULL"); conn = NULL; } else if (protocol == PROTO_GIT) { + /* + * Set up virtual host information based on where we will + * connect, unless the user has overridden us in + * the environment. + */ + char *target_host = getenv("GIT_OVERRIDE_VIRTUAL_HOST"); + if (target_host) + target_host = xstrdup(target_host); + else + target_host = xstrdup(hostandport); + /* These underlying connection commands die() if they * cannot connect. */ - char *target_host = xstrdup(hostandport); if (git_use_proxy(hostandport)) conn = git_proxy_connect(fd, hostandport); else @@@ -721,15 -714,13 +723,15 @@@ conn->in = conn->out = -1; if (protocol == PROTO_SSH) { - const char *ssh = getenv("GIT_SSH"); - int putty = ssh && strcasestr(ssh, "plink"); + const char *ssh; + int putty; char *ssh_host = hostandport; const char *port = NULL; get_host_and_port(&ssh_host, &port); + if (!port) port = get_port(ssh_host); + if (flags & CONNECT_DIAG_URL) { printf("Diag: url=%s\n", url ? url : "NULL"); printf("Diag: protocol=%s\n", prot_name(protocol)); @@@ -741,16 -732,7 +743,16 @@@ free(path); return NULL; } else { - if (!ssh) ssh = "ssh"; + ssh = getenv("GIT_SSH_COMMAND"); + if (ssh) { + conn->use_shell = 1; + putty = 0; + } else { + ssh = getenv("GIT_SSH"); + if (!ssh) + ssh = "ssh"; + putty = !!strcasestr(ssh, "plink"); + } argv_array_push(&conn->args, ssh); if (putty && !strcasestr(ssh, "tortoiseplink"))