Post 2.3 cycle (batch #6)
[gitweb.git] / connect.c
index d47d0ec6040fdb8b07a689e299dac121bb468717..372ac5ad9d16b7bc3f7e03012656b1541af5ba4c 100644 (file)
--- a/connect.c
+++ b/connect.c
@@ -93,7 +93,7 @@ static void annotate_refs_with_symref_info(struct ref *ref)
                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;
@@ -670,10 +670,20 @@ struct child_process *git_connect(int fd[2], const char *url,
                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
@@ -700,14 +710,23 @@ struct child_process *git_connect(int fd[2], const char *url,
 
                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);
                        port = get_port_numeric(port);
 
-                       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"))