{"thread":{"id":"35428","subject":"[PATCH v7 07/10] git fetch: support host:/~repo","startedAt":"2013-11-28T19:49:38Z","lastAt":"2013-11-28T19:49:38Z","messageCount":1,"participants":["Torsten Bögershausen"],"isPatch":true,"patchVersion":7,"patchTotal":10},"messages":[{"id":"231258","messageId":"201311282049.39434.tboegi@web.de","threadId":"35428","inReplyTo":null,"subject":"[PATCH v7 07/10] git fetch: support host:/~repo","fromName":"Torsten Bögershausen","fromEmail":"tboegi@web.de","sentAt":"2013-11-28T19:49:38Z","receivedAt":"2013-11-28T19:49:38Z","isPatch":true,"sender":{"key":"tboegi@web.de","avatar":"https://avatars.githubusercontent.com/u/7138363?v=4"},"body":"The documentation (in urls.txt) says that\n\"ssh://host:/~repo\",\n\"host:/~repo\" or\n\"host:~repo\"\nspecifiy the repository \"repo\" in the home directory at \"host\".\n\nThis has not been working for \"host:/~repo\".\n\nFix a minor regression:\nBefore commit 356bec \"Support [address] in URLs\"\nthe comparison url != hostname could be used to determine if\nthe URL had a scheme or not: \"ssh://host/host\" != \"host\".\nAfter 356bec \"[::1]\" was converted into \"::1\", yielding\nurl != hostname as well.\nSolution:\nDon't use \"if (url != hostname)\", but look at the separator instead.\nRename the variable \"c\" into separator.\n\nSigned-off-by: Torsten Bögershausen <tboegi@web.de>\n---\n connect.c             | 14 +++++++-------\n t/t5500-fetch-pack.sh | 24 ++++++++++++++++++++++++\n t/t5601-clone.sh      | 12 ++----------\n 3 files changed, 33 insertions(+), 17 deletions(-)\n\ndiff --git a/connect.c b/connect.c\nindex a16bdaf..7e5f608 100644\n--- a/connect.c\n+++ b/connect.c\n@@ -567,7 +567,7 @@ static enum protocol parse_connect_url(const char *url_orig, char **ret_host,\n \tchar *url;\n \tchar *host, *path;\n \tchar *end;\n-\tint c;\n+\tint separator;\n \tenum protocol protocol = PROTO_LOCAL;\n \tint free_path = 0;\n \tchar *port = NULL;\n@@ -582,10 +582,10 @@ static enum protocol parse_connect_url(const char *url_orig, char **ret_host,\n \t\t*host = '\\0';\n \t\tprotocol = get_protocol(url);\n \t\thost += 3;\n-\t\tc = '/';\n+\t\tseparator = '/';\n \t} else {\n \t\thost = url;\n-\t\tc = ':';\n+\t\tseparator = ':';\n \t}\n \n \t/*\n@@ -605,9 +605,9 @@ static enum protocol parse_connect_url(const char *url_orig, char **ret_host,\n \t} else\n \t\tend = host;\n \n-\tpath = strchr(end, c);\n+\tpath = strchr(end, separator);\n \tif (path && !has_dos_drive_prefix(end)) {\n-\t\tif (c == ':') {\n+\t\tif (separator == ':') {\n \t\t\tif (host != url || path < strchrnul(host, '/')) {\n \t\t\t\tprotocol = PROTO_SSH;\n \t\t\t\t*path++ = '\\0';\n@@ -624,7 +624,7 @@ static enum protocol parse_connect_url(const char *url_orig, char **ret_host,\n \t * null-terminate hostname and point path to ~ for URL's like this:\n \t *    ssh://host.xz/~user/repo\n \t */\n-\tif (protocol != PROTO_LOCAL && host != url) {\n+\tif (protocol != PROTO_LOCAL) {\n \t\tchar *ptr = path;\n \t\tif (path[1] == '~')\n \t\t\tpath++;\n@@ -639,7 +639,7 @@ static enum protocol parse_connect_url(const char *url_orig, char **ret_host,\n \t/*\n \t * Add support for ssh port: ssh://host.xy:<port>/...\n \t */\n-\tif (protocol == PROTO_SSH && host != url)\n+\tif (protocol == PROTO_SSH && separator == '/')\n \t\tport = get_port(end);\n \n \t*ret_host = xstrdup(host);\ndiff --git a/t/t5500-fetch-pack.sh b/t/t5500-fetch-pack.sh\nindex a2b37af..2d3cdaa 100755\n--- a/t/t5500-fetch-pack.sh\n+++ b/t/t5500-fetch-pack.sh\n@@ -589,6 +589,30 @@ do\n \t\t\tcheck_prot_path $p://$h/~$r $p \"/~$r\"\n \t\t'\n \tdone\n+\t# file without scheme\n+\tfor h in nohost nohost:12 [::1] [::1]:23 [ [:aa\n+\tdo\n+\t\ttest_expect_success \"fetch-pack --diag-url ./$h:$r\" '\n+\t\t\tcheck_prot_path ./$h:$r $p \"./$h:$r\"\n+\t\t'\n+\t\t# No \"/~\" -> \"~\" conversion for file\n+\t\ttest_expect_success \"fetch-pack --diag-url ./$p:$h/~$r\" '\n+\t\tcheck_prot_path ./$p:$h/~$r $p \"./$p:$h/~$r\"\n+\t\t'\n+\tdone\n+\t#ssh without scheme\n+\tp=ssh\n+\tfor h in host [::1]\n+\tdo\n+\t\thh=$(echo $h | tr -d \"[]\")\n+\t\ttest_expect_success \"fetch-pack --diag-url $h:$r\" '\n+\t\t\tcheck_prot_path $h:$r $p \"$r\"\n+\t\t'\n+\t\t# Do \"/~\" -> \"~\" conversion\n+\t\ttest_expect_success \"fetch-pack --diag-url $h:/~$r\" '\n+\t\t\tcheck_prot_host_path $h:/~$r $p \"$hh\" \"~$r\"\n+\t\t'\n+\tdone\n done\n \n test_done\ndiff --git a/t/t5601-clone.sh b/t/t5601-clone.sh\nindex ba99972..4db0c0b 100755\n--- a/t/t5601-clone.sh\n+++ b/t/t5601-clone.sh\n@@ -348,7 +348,7 @@ test_expect_success MINGW 'clone c:temp is dos drive' '\n '\n \n #ip v4\n-for repo in rep rep/home/project /~proj 123\n+for repo in rep rep/home/project 123\n do\n \ttest_expect_success \"clone host:$repo\" '\n \t\ttest_clone_url host:$repo host $repo\n@@ -356,14 +356,6 @@ do\n done\n \n #ipv6\n-# failing\n-for repo in /~proj\n-do\n-\ttest_expect_failure \"clone [::1]:$repo\" '\n-\t\ttest_clone_url [::1]:$repo ::1 $repo\n-\t'\n-done\n-\n for repo in rep rep/home/project 123\n do\n \ttest_expect_success \"clone [::1]:$repo\" '\n@@ -373,7 +365,7 @@ done\n \n # Corner cases\n # failing\n-for repo in [foo]bar/baz:qux [foo/bar]:baz\n+for url in [foo]bar/baz:qux [foo/bar]:baz\n do\n \ttest_expect_failure \"clone $url is not ssh\" '\n \t\ttest_clone_url $url none\n-- \n1.8.5.rc0.23.gaa27064\n"}]}