From: Junio C Hamano Date: Mon, 20 Apr 2015 22:28:33 +0000 (-0700) Subject: Merge branch 'tb/connect-ipv6-parse-fix' X-Git-Tag: v2.4.0-rc3~5 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/9718c7c0c2a92585729d0f2e05ebf2c44b0cc56a?ds=inline;hp=-c Merge branch 'tb/connect-ipv6-parse-fix' An earlier update to the parser that disects an address broke an address, followed by a colon, followed by an empty string (instead of the port number). * tb/connect-ipv6-parse-fix: connect.c: ignore extra colon after hostname --- 9718c7c0c2a92585729d0f2e05ebf2c44b0cc56a diff --combined connect.c index 6090211fe9,dc31b795e7..391d21192f --- 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)); @@@ -739,19 -730,9 +741,19 @@@ free(hostandport); free(path); + free(conn); 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")) diff --combined t/t5500-fetch-pack.sh index 692d71738b,ed40407309..3a9b77576f --- a/t/t5500-fetch-pack.sh +++ b/t/t5500-fetch-pack.sh @@@ -414,7 -414,7 +414,7 @@@ test_expect_success 'setup tests for th do git tag $head $head done && - cat >input <<-\EOF + cat >input <<-\EOF && refs/heads/C refs/heads/A refs/heads/D @@@ -576,13 -576,16 +576,16 @@@ d do for h in host user@host user@[::1] user@::1 do - test_expect_success "fetch-pack --diag-url $p://$h/$r" ' - check_prot_host_port_path $p://$h/$r $p "$h" NONE "/$r" - ' - # "/~" -> "~" conversion - test_expect_success "fetch-pack --diag-url $p://$h/~$r" ' - check_prot_host_port_path $p://$h/~$r $p "$h" NONE "~$r" - ' + for c in "" : + do + test_expect_success "fetch-pack --diag-url $p://$h$c/$r" ' + check_prot_host_port_path $p://$h/$r $p "$h" NONE "/$r" + ' + # "/~" -> "~" conversion + test_expect_success "fetch-pack --diag-url $p://$h$c/~$r" ' + check_prot_host_port_path $p://$h/~$r $p "$h" NONE "~$r" + ' + done done for h in host User@host User@[::1] do