git fetch: support host:/~repo
The documentation (in urls.txt) says that "ssh://host:/~repo", "host:/~repo" or "host:~repo" specify the repository "repo" in the home directory at "host". This has not been working for "host:/~repo". Before commit 356bec "Support [address] in URLs", the comparison "url != hostname" could be used to determine if the URL had a scheme or not: "ssh://host/host" != "host". However, after 356bec "[::1]" was converted into "::1", yielding url != hostname as well. To fix this regression, don't use "if (url != hostname)", but look at the separator instead. Rename the variable "c" into "separator" to make it easier to read. Signed-off-by: Torsten Bögershausen <tboegi@web.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
parent
854aeb7beb
commit
6a59974869
14
connect.c
14
connect.c
@ -567,7 +567,7 @@ static enum protocol parse_connect_url(const char *url_orig, char **ret_host,
|
|||||||
char *url;
|
char *url;
|
||||||
char *host, *path;
|
char *host, *path;
|
||||||
char *end;
|
char *end;
|
||||||
int c;
|
int separator;
|
||||||
enum protocol protocol = PROTO_LOCAL;
|
enum protocol protocol = PROTO_LOCAL;
|
||||||
int free_path = 0;
|
int free_path = 0;
|
||||||
char *port = NULL;
|
char *port = NULL;
|
||||||
@ -582,10 +582,10 @@ static enum protocol parse_connect_url(const char *url_orig, char **ret_host,
|
|||||||
*host = '\0';
|
*host = '\0';
|
||||||
protocol = get_protocol(url);
|
protocol = get_protocol(url);
|
||||||
host += 3;
|
host += 3;
|
||||||
c = '/';
|
separator = '/';
|
||||||
} else {
|
} else {
|
||||||
host = url;
|
host = url;
|
||||||
c = ':';
|
separator = ':';
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -605,9 +605,9 @@ static enum protocol parse_connect_url(const char *url_orig, char **ret_host,
|
|||||||
} else
|
} else
|
||||||
end = host;
|
end = host;
|
||||||
|
|
||||||
path = strchr(end, c);
|
path = strchr(end, separator);
|
||||||
if (path && !has_dos_drive_prefix(end)) {
|
if (path && !has_dos_drive_prefix(end)) {
|
||||||
if (c == ':') {
|
if (separator == ':') {
|
||||||
if (host != url || path < strchrnul(host, '/')) {
|
if (host != url || path < strchrnul(host, '/')) {
|
||||||
protocol = PROTO_SSH;
|
protocol = PROTO_SSH;
|
||||||
*path++ = '\0';
|
*path++ = '\0';
|
||||||
@ -624,7 +624,7 @@ static enum protocol parse_connect_url(const char *url_orig, char **ret_host,
|
|||||||
* null-terminate hostname and point path to ~ for URL's like this:
|
* null-terminate hostname and point path to ~ for URL's like this:
|
||||||
* ssh://host.xz/~user/repo
|
* ssh://host.xz/~user/repo
|
||||||
*/
|
*/
|
||||||
if (protocol != PROTO_LOCAL && host != url) {
|
if (protocol != PROTO_LOCAL) {
|
||||||
char *ptr = path;
|
char *ptr = path;
|
||||||
if (path[1] == '~')
|
if (path[1] == '~')
|
||||||
path++;
|
path++;
|
||||||
@ -639,7 +639,7 @@ static enum protocol parse_connect_url(const char *url_orig, char **ret_host,
|
|||||||
/*
|
/*
|
||||||
* Add support for ssh port: ssh://host.xy:<port>/...
|
* Add support for ssh port: ssh://host.xy:<port>/...
|
||||||
*/
|
*/
|
||||||
if (protocol == PROTO_SSH && host != url)
|
if (protocol == PROTO_SSH && separator == '/')
|
||||||
port = get_port(end);
|
port = get_port(end);
|
||||||
|
|
||||||
*ret_host = xstrdup(host);
|
*ret_host = xstrdup(host);
|
||||||
|
@ -589,6 +589,30 @@ do
|
|||||||
check_prot_path $p://$h/~$r $p "/~$r"
|
check_prot_path $p://$h/~$r $p "/~$r"
|
||||||
'
|
'
|
||||||
done
|
done
|
||||||
|
# file without scheme
|
||||||
|
for h in nohost nohost:12 [::1] [::1]:23 [ [:aa
|
||||||
|
do
|
||||||
|
test_expect_success "fetch-pack --diag-url ./$h:$r" '
|
||||||
|
check_prot_path ./$h:$r $p "./$h:$r"
|
||||||
|
'
|
||||||
|
# No "/~" -> "~" conversion for file
|
||||||
|
test_expect_success "fetch-pack --diag-url ./$p:$h/~$r" '
|
||||||
|
check_prot_path ./$p:$h/~$r $p "./$p:$h/~$r"
|
||||||
|
'
|
||||||
|
done
|
||||||
|
#ssh without scheme
|
||||||
|
p=ssh
|
||||||
|
for h in host [::1]
|
||||||
|
do
|
||||||
|
hh=$(echo $h | tr -d "[]")
|
||||||
|
test_expect_success "fetch-pack --diag-url $h:$r" '
|
||||||
|
check_prot_path $h:$r $p "$r"
|
||||||
|
'
|
||||||
|
# Do "/~" -> "~" conversion
|
||||||
|
test_expect_success "fetch-pack --diag-url $h:/~$r" '
|
||||||
|
check_prot_host_path $h:/~$r $p "$hh" "~$r"
|
||||||
|
'
|
||||||
|
done
|
||||||
done
|
done
|
||||||
|
|
||||||
test_done
|
test_done
|
||||||
|
@ -348,7 +348,7 @@ test_expect_success MINGW 'clone c:temp is dos drive' '
|
|||||||
'
|
'
|
||||||
|
|
||||||
#ip v4
|
#ip v4
|
||||||
for repo in rep rep/home/project /~proj 123
|
for repo in rep rep/home/project 123
|
||||||
do
|
do
|
||||||
test_expect_success "clone host:$repo" '
|
test_expect_success "clone host:$repo" '
|
||||||
test_clone_url host:$repo host $repo
|
test_clone_url host:$repo host $repo
|
||||||
@ -356,14 +356,6 @@ do
|
|||||||
done
|
done
|
||||||
|
|
||||||
#ipv6
|
#ipv6
|
||||||
# failing
|
|
||||||
for repo in /~proj
|
|
||||||
do
|
|
||||||
test_expect_failure "clone [::1]:$repo" '
|
|
||||||
test_clone_url [::1]:$repo ::1 $repo
|
|
||||||
'
|
|
||||||
done
|
|
||||||
|
|
||||||
for repo in rep rep/home/project 123
|
for repo in rep rep/home/project 123
|
||||||
do
|
do
|
||||||
test_expect_success "clone [::1]:$repo" '
|
test_expect_success "clone [::1]:$repo" '
|
||||||
@ -373,7 +365,7 @@ done
|
|||||||
|
|
||||||
# Corner cases
|
# Corner cases
|
||||||
# failing
|
# failing
|
||||||
for repo in [foo]bar/baz:qux [foo/bar]:baz
|
for url in [foo]bar/baz:qux [foo/bar]:baz
|
||||||
do
|
do
|
||||||
test_expect_failure "clone $url is not ssh" '
|
test_expect_failure "clone $url is not ssh" '
|
||||||
test_clone_url $url none
|
test_clone_url $url none
|
||||||
|
Loading…
Reference in New Issue
Block a user