{"thread":{"id":"2299","subject":"[PATCH 1/4] Client side of user-relative paths, take two.","startedAt":"2005-11-01T22:59:21Z","lastAt":"2005-11-02T08:19:37Z","messageCount":3,"participants":["Andreas Ericsson","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":4},"messages":[{"id":"10955","messageId":"20051101225921.245595BF70@nox.op5.se","threadId":"2299","inReplyTo":null,"subject":"[PATCH 1/4] Client side of user-relative paths, take two.","fromName":"Andreas Ericsson","fromEmail":"ae@op5.se","sentAt":"2005-11-01T22:59:21Z","receivedAt":"2005-11-01T22:59:21Z","isPatch":true,"sender":{"key":"ae@op5.se","avatar":"https://gravatar.com/avatar/426e89595c75a8f5252dd0c989e5fabe5bcac616e68557427ad9aef6b0ca342a?d=mp&s=160"},"body":"See this discussion, \"[RFC] GIT paths\", on the git-list:\nhttp://www.gelato.unsw.edu.au/archives/git/0510/10924.html\n\nIn particular, the client side now passes identical paths for these two:\n\tssh://host.xz/~junio/repo\n\thost.xz:~junio/repo\n\nA friendly error message is produced if no path is specified.\n\nSigned-off-by: Andreas Ericsson <ae@op5.se>\n\n---\n\n connect.c |   53 ++++++++++++++++++++++++++++++++++-------------------\n 1 files changed, 34 insertions(+), 19 deletions(-)\n\napplies-to: e39c96179f2cc5064a0255057b8e8a8863594536\n22ca6db517baf2bb4824a971408543d9bd956209\ndiff --git a/connect.c b/connect.c\nindex c2badc7..9150ad2 100644\n--- a/connect.c\n+++ b/connect.c\n@@ -460,26 +460,41 @@ int git_connect(int fd[2], char *url, co\n \tpid_t pid;\n \tenum protocol protocol;\n \n-\thost = NULL;\n-\tpath = url;\n-\tcolon = strchr(url, ':');\n-\tprotocol = PROTO_LOCAL;\n-\tif (colon) {\n-\t\t*colon = 0;\n+\tprotocol = PROTO_SSH;\n+\thost = strstr(url, \"://\");\n+\tif(host) {\n+\t\t*host = '\\0';\n+\t\tprotocol = get_protocol(url);\n+\t\thost += 3;\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\t}\n+\n+\tpath = strchr(host, '/');\n+\tcolon = strchr(host, ':');\n+\n+\t/* We keep server-side code simple by handling the difference\n+\t * between these two on the client side:\n+\t *    ssh://host.xz/~user/repo\n+\t *    host.xz:~repo\n+\t */\n+\tif (protocol == PROTO_SSH && colon && (!path || colon < path)) {\n+\t\t*colon = 0;\n+\t\tpath = colon + 1;\n+\t}\n+\n+\tif(!path || !*path)\n+\t\tdie(\"No path specified. Try '%s%s/path/to/repo'\", url, colon ? \":\" : \"\");\n+\n+\t/* null-terminate host part and point path to ~ for URL's like this:\n+\t *    ssh://host.xz/~user/repo\n+\t */\n+\tif(!colon && *(path + 1) == '~')\n+\t\t*path++ = '\\0';\n+\telse {\n+\t\tcolon = path;\n+\t\tpath = strdup(path);\n+\t\t*colon = '\\0';\n \t}\n \n \tif (protocol == PROTO_GIT)\n---\n0.99.9.GIT\n"},{"id":"10970","messageId":"7vpspj6h3n.fsf@assigned-by-dhcp.cox.net","threadId":"2299","inReplyTo":"20051101225921.245595BF70@nox.op5.se","subject":"Re: [PATCH 1/4] Client side of user-relative paths, take two.","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2005-11-02T00:14:36Z","receivedAt":"2005-11-02T00:14:36Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Andreas Ericsson <ae@op5.se> writes:\n\n> +\tif (protocol == PROTO_SSH && colon && (!path || colon < path)) {\n> +\t\t*colon = 0;\n> +\t\tpath = colon + 1;\n> +\t}\n\nI think \"colon < path\" is to cover \"git://host.xz/foo/bar:baz\"\ncase (i.e. funny directory name with an embedded colon); I think\nyou should reset colon to NULL if you do things differently\nlater depending on colon is set or not, like this part:\n\n> +\t/* null-terminate host part and point path to ~ for URL's like this:\n> +\t *    ssh://host.xz/~user/repo\n> +\t */\n> +\tif(!colon && *(path + 1) == '~')\n> +\t\t*path++ = '\\0';\n> +\telse {\n> +\t\tcolon = path;\n> +\t\tpath = strdup(path);\n> +\t\t*colon = '\\0';\n"},{"id":"10997","messageId":"43687699.8060609@op5.se","threadId":"2299","inReplyTo":"7vpspj6h3n.fsf@assigned-by-dhcp.cox.net","subject":"Re: [PATCH 1/4] Client side of user-relative paths, take two.","fromName":"Andreas Ericsson","fromEmail":"ae@op5.se","sentAt":"2005-11-02T08:19:37Z","receivedAt":"2005-11-02T08:19:37Z","isPatch":true,"sender":{"key":"ae@op5.se","avatar":"https://gravatar.com/avatar/426e89595c75a8f5252dd0c989e5fabe5bcac616e68557427ad9aef6b0ca342a?d=mp&s=160"},"body":"Junio C Hamano wrote:\n> Andreas Ericsson <ae@op5.se> writes:\n> \n> \n>>+\tif (protocol == PROTO_SSH && colon && (!path || colon < path)) {\n>>+\t\t*colon = 0;\n>>+\t\tpath = colon + 1;\n>>+\t}\n> \n> \n> I think \"colon < path\" is to cover \"git://host.xz/foo/bar:baz\"\n> case (i.e. funny directory name with an embedded colon); I think\n> you should reset colon to NULL if you do things differently\n> later depending on colon is set or not, like this part:\n> \n> \n>>+\t/* null-terminate host part and point path to ~ for URL's like this:\n>>+\t *    ssh://host.xz/~user/repo\n>>+\t */\n>>+\tif(!colon && *(path + 1) == '~')\n>>+\t\t*path++ = '\\0';\n>>+\telse {\n>>+\t\tcolon = path;\n>>+\t\tpath = strdup(path);\n>>+\t\t*colon = '\\0';\n> \n> \n\nTrue. Should I update this patch or submit a new one fixing only this \nspecific issue?\n\n-- \nAndreas Ericsson                   andreas.ericsson@op5.se\nOP5 AB                             www.op5.se\nTel: +46 8-230225                  Fax: +46 8-230231\n"}]}