{"thread":{"id":"2571","subject":"[PATCH 3/5] Client side support for user-relative paths.","startedAt":"2005-11-17T19:37:14Z","lastAt":"2005-11-17T19:37:14Z","messageCount":1,"participants":["Andreas Ericsson"],"isPatch":true,"patchVersion":1,"patchTotal":5},"messages":[{"id":"12132","messageId":"20051117193714.3CCC35C7F6@nox.op5.se","threadId":"2571","inReplyTo":null,"subject":"[PATCH 3/5] Client side support for user-relative paths.","fromName":"Andreas Ericsson","fromEmail":"exon@op5.se","sentAt":"2005-11-17T19:37:14Z","receivedAt":"2005-11-17T19:37:14Z","isPatch":true,"sender":{"key":"exon@op5.se","avatar":"https://gravatar.com/avatar/b948c4f759e868f8e721e545e37afe2cf89cfa8e2ee8b70a432f0d76aee39891?d=mp&s=160"},"body":"\nWith this patch, the client side passes identical paths for these two:\n\tssh://host.xz/~junio/repo\n\thost.xz:~junio/repo\n\nSigned-off-by: Andreas Ericsson <ae@op5.se>\n\n---\n\n connect.c |   53 ++++++++++++++++++++++++++++++++---------------------\n 1 files changed, 32 insertions(+), 21 deletions(-)\n\napplies-to: cd3bc724fea293b623abee6b0b4995560dd9f32e\nc460d84cc8431089ddf6a888a418826ff8248509\ndiff --git a/connect.c b/connect.c\nindex c2badc7..73187a1 100644\n--- a/connect.c\n+++ b/connect.c\n@@ -454,34 +454,45 @@ static int git_tcp_connect(int fd[2], co\n int git_connect(int fd[2], char *url, const char *prog)\n {\n \tchar command[1024];\n-\tchar *host, *path;\n-\tchar *colon;\n+\tchar *host, *path = url;\n+\tchar *colon = NULL;\n \tint pipefd[2][2];\n \tpid_t pid;\n-\tenum protocol protocol;\n+\tenum protocol protocol = PROTO_LOCAL;\n \n-\thost = NULL;\n-\tpath = url;\n-\tcolon = strchr(url, ':');\n-\tprotocol = PROTO_LOCAL;\n-\tif (colon) {\n-\t\t*colon = 0;\n+\thost = strstr(url, \"://\");\n+\tif(host) {\n+\t\t*host = '\\0';\n+\t\tprotocol = get_protocol(url);\n+\t\thost += 3;\n+\t\tpath = strchr(host, '/');\n+\t}\n+\telse {\n \t\thost = url;\n-\t\tpath = colon+1;\n-\t\tprotocol = PROTO_SSH;\n-\t\tif (!memcmp(path, \"//\", 2)) {\n-\t\t\tchar *slash = strchr(path + 2, '/');\n-\t\t\tif (slash) {\n-\t\t\t\tint nr = slash - path - 2;\n-\t\t\t\tmemmove(path, path+2, nr);\n-\t\t\t\tpath[nr] = 0;\n-\t\t\t\tprotocol = get_protocol(url);\n-\t\t\t\thost = path;\n-\t\t\t\tpath = slash;\n-\t\t\t}\n+\t\tif ((colon = strchr(host, ':'))) {\n+\t\t\tprotocol = PROTO_SSH;\n+\t\t\t*colon = '\\0';\n+\t\t\tpath = colon + 1;\n \t\t}\n \t}\n \n+\tif (!path || !*path)\n+\t\tdie(\"No path specified. See 'man git-pull' for valid url syntax\");\n+\n+\t/*\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+\t\tchar *ptr = path;\n+\t\tif (path[1] == '~')\n+\t\t\tpath++;\n+\t\telse\n+\t\t\tpath = strdup(ptr);\n+\n+\t\t*ptr = '\\0';\n+\t}\n+\n \tif (protocol == PROTO_GIT)\n \t\treturn git_tcp_connect(fd, prog, host, path);\n \n---\n0.99.9.GIT\n"}]}