]> git.ipfire.org Git - thirdparty/git.git/commitdiff
Merge branch 'tb/connect-ipv6-parse-fix' into maint
authorJunio C Hamano <gitster@pobox.com>
Mon, 27 Apr 2015 19:23:53 +0000 (12:23 -0700)
committerJunio C Hamano <gitster@pobox.com>
Mon, 27 Apr 2015 19:23:54 +0000 (12:23 -0700)
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

1  2 
connect.c

diff --combined connect.c
index ce0e1214234244236a407e9f3004e619d26c54a8,dc31b795e735bdcb47f4c3c54f3236406578aaa0..14c924b030cc17e083d4b8662faf5c6d48f68d85
+++ 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
  
                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));
                                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"))