xdiff/xhistogram: move index allocation into find_lcs
[gitweb.git] / connect.c
index d77d39771b6c5101abe14df1e078af2a02ce8ace..048fa049170c8f6912ac96b7b547f2f28a74995e 100644 (file)
--- a/connect.c
+++ b/connect.c
@@ -267,9 +267,9 @@ static enum protocol get_protocol(const char *name)
                return PROTO_SSH;
        if (!strcmp(name, "git"))
                return PROTO_GIT;
-       if (!strcmp(name, "git+ssh"))
+       if (!strcmp(name, "git+ssh")) /* deprecated - do not use */
                return PROTO_SSH;
-       if (!strcmp(name, "ssh+git"))
+       if (!strcmp(name, "ssh+git")) /* deprecated - do not use */
                return PROTO_SSH;
        if (!strcmp(name, "file"))
                return PROTO_FILE;
@@ -357,6 +357,10 @@ static int git_tcp_connect_sock(char *host, int flags)
                port = "<none>";
 
        memset(&hints, 0, sizeof(hints));
+       if (flags & CONNECT_IPV4)
+               hints.ai_family = AF_INET;
+       else if (flags & CONNECT_IPV6)
+               hints.ai_family = AF_INET6;
        hints.ai_socktype = SOCK_STREAM;
        hints.ai_protocol = IPPROTO_TCP;
 
@@ -659,6 +663,19 @@ static enum protocol parse_connect_url(const char *url_orig, char **ret_host,
 
 static struct child_process no_fork = CHILD_PROCESS_INIT;
 
+static const char *get_ssh_command(void)
+{
+       const char *ssh;
+
+       if ((ssh = getenv("GIT_SSH_COMMAND")))
+               return ssh;
+
+       if (!git_config_get_string_const("core.sshcommand", &ssh))
+               return ssh;
+
+       return NULL;
+}
+
 /*
  * This returns a dummy child_process if the transport protocol does not
  * need fork(2), or a struct child_process object if it does.  Once done,
@@ -765,7 +782,7 @@ struct child_process *git_connect(int fd[2], const char *url,
                        if (looks_like_command_line_option(ssh_host))
                                die("strange hostname '%s' blocked", ssh_host);
 
-                       ssh = getenv("GIT_SSH_COMMAND");
+                       ssh = get_ssh_command();
                        if (!ssh) {
                                const char *base;
                                char *ssh_dup;
@@ -794,6 +811,10 @@ struct child_process *git_connect(int fd[2], const char *url,
                        }
 
                        argv_array_push(&conn->args, ssh);
+                       if (flags & CONNECT_IPV4)
+                               argv_array_push(&conn->args, "-4");
+                       else if (flags & CONNECT_IPV6)
+                               argv_array_push(&conn->args, "-6");
                        if (tortoiseplink)
                                argv_array_push(&conn->args, "-batch");
                        if (port) {