{"thread":{"id":"17234","subject":"[PATCH] http-push: support full URI in handle_remote_ls_ctx()","startedAt":"2009-01-18T11:28:36Z","lastAt":"2009-01-18T21:28:04Z","messageCount":3,"participants":["Kirill A. Korinskiy","Johannes Schindelin","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"100948","messageId":"1232278116-6631-1-git-send-email-catap@catap.ru","threadId":"17234","inReplyTo":null,"subject":"[PATCH] http-push: support full URI in handle_remote_ls_ctx()","fromName":"Kirill A. Korinskiy","fromEmail":"catap@catap.ru","sentAt":"2009-01-18T11:28:36Z","receivedAt":"2009-01-18T11:28:36Z","isPatch":true,"sender":{"key":"catap@catap.ru","avatar":"https://gravatar.com/avatar/ea0ab2c29579606bd684eccdf786c666f4425bedc4e599b698a175f12737b1c5?d=mp&s=160"},"body":"The program calls remote_ls() to get list of files from the server\nover HTTP; handle_remote_ls_ctx() is used to parse its response to\npopulate \"struct remote_ls_ctx\" that is returned from remote_ls().\n\nThe handle_remote_ls_ctx() function assumed that the server returns a\nlocal path in href field, but RFC 4918 (14.7) demand of support full\nURI (e.g. \"http://localhost:8080/repo.git\").\n\nThis resulted in push failure (e.g. git-http-push issues a PROPFIND\nrequest to \"/repo.git/alhost:8080/repo.git/refs/\" to the server).\n\nSigned-off-by: Kirill A. Korinskiy <catap@catap.ru>\n---\n http-push.c |   24 ++++++++++++++++++------\n 1 files changed, 18 insertions(+), 6 deletions(-)\n\ndiff --git a/http-push.c b/http-push.c\nindex 7c6460919bf3eba10c46cede11ffdd9c53fd2dd2..2cb925a9ad857b6d79858d5187f14072167282e7 100644\n--- a/http-push.c\n+++ b/http-push.c\n@@ -87,6 +87,7 @@ static struct object_list *objects;\n struct repo\n {\n \tchar *url;\n+\tchar *path;\n \tint path_len;\n \tint has_info_refs;\n \tint can_update_info_refs;\n@@ -1424,9 +1425,18 @@ static void handle_remote_ls_ctx(struct xml_ctx *ctx, int tag_closed)\n \t\t\t\tls->userFunc(ls);\n \t\t\t}\n \t\t} else if (!strcmp(ctx->name, DAV_PROPFIND_NAME) && ctx->cdata) {\n-\t\t\tls->dentry_name = xmalloc(strlen(ctx->cdata) -\n+\t\t\tchar *path = ctx->cdata;\n+\t\t\tif (!strcmp(ctx->cdata, \"http://\")) {\n+\t\t\t\tpath = strchr(path + sizeof(\"http://\") - 1, '/');\n+\t\t\t} else if (!strcmp(ctx->cdata, \"https://\")) {\n+\t\t\t\tpath = strchr(path + sizeof(\"https://\") - 1, '/');\n+\t\t\t}\n+\n+\t\t\tpath += remote->path_len;\n+\n+\t\t\tls->dentry_name = xmalloc(strlen(path) -\n \t\t\t\t\t\t  remote->path_len + 1);\n-\t\t\tstrcpy(ls->dentry_name, ctx->cdata + remote->path_len);\n+\t\t\tstrcpy(ls->dentry_name, path + remote->path_len);\n \t\t} else if (!strcmp(ctx->name, DAV_PROPFIND_COLLECTION)) {\n \t\t\tls->dentry_flags |= IS_DIR;\n \t\t}\n@@ -2206,10 +2216,11 @@ int main(int argc, char **argv)\n \t\tif (!remote->url) {\n \t\t\tchar *path = strstr(arg, \"//\");\n \t\t\tremote->url = arg;\n+\t\t\tremote->path_len = strlen(arg);\n \t\t\tif (path) {\n-\t\t\t\tpath = strchr(path+2, '/');\n-\t\t\t\tif (path)\n-\t\t\t\t\tremote->path_len = strlen(path);\n+\t\t\t\tremote->path = strchr(path+2, '/');\n+\t\t\t\tif (remote->path)\n+\t\t\t\t\tremote->path_len = strlen(remote->path);\n \t\t\t}\n \t\t\tcontinue;\n \t\t}\n@@ -2238,8 +2249,9 @@ int main(int argc, char **argv)\n \t\trewritten_url = xmalloc(strlen(remote->url)+2);\n \t\tstrcpy(rewritten_url, remote->url);\n \t\tstrcat(rewritten_url, \"/\");\n+\t\tremote->path = rewritten_url + (remote->path - remote->url);\n+\t\tremote->path_len++;\n \t\tremote->url = rewritten_url;\n-\t\t++remote->path_len;\n \t}\n \n \t/* Verify DAV compliance/lock support */\n-- \n1.5.6.5\n"},{"id":"100979","messageId":"alpine.DEB.1.00.0901181546100.3586@pacific.mpi-cbg.de","threadId":"17234","inReplyTo":"1232278116-6631-1-git-send-email-catap@catap.ru","subject":"Re: [PATCH] http-push: support full URI in handle_remote_ls_ctx()","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2009-01-18T14:51:39Z","receivedAt":"2009-01-18T14:51:39Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Sun, 18 Jan 2009, Kirill A. Korinskiy wrote:\n\n> The program calls remote_ls() to get list of files from the server\n> over HTTP; handle_remote_ls_ctx() is used to parse its response to\n> populate \"struct remote_ls_ctx\" that is returned from remote_ls().\n> \n> The handle_remote_ls_ctx() function assumed that the server returns a\n> local path in href field, but RFC 4918 (14.7) demand of support full\n> URI (e.g. \"http://localhost:8080/repo.git\").\n> \n> This resulted in push failure (e.g. git-http-push issues a PROPFIND\n> request to \"/repo.git/alhost:8080/repo.git/refs/\" to the server).\n> \n> Signed-off-by: Kirill A. Korinskiy <catap@catap.ru>\n> ---\n>  http-push.c |   24 ++++++++++++++++++------\n>  1 files changed, 18 insertions(+), 6 deletions(-)\n> \n> diff --git a/http-push.c b/http-push.c\n> index 7c6460919bf3eba10c46cede11ffdd9c53fd2dd2..2cb925a9ad857b6d79858d5187f14072167282e7 100644\n\nYou mean this patch is not vs \njunio/next(bbe7a8ed3dac72b7a1372cd92f68f47965c10100) or junio/master or \njunio/maint(both a4b7d08663504a57008f66a39fffe293f62c1d08) but \ntags/v1.6.1-rc4~13?\n\nCiao,\nDscho\n"},{"id":"101063","messageId":"7v63kcuwwr.fsf@gitster.siamese.dyndns.org","threadId":"17234","inReplyTo":"1232278116-6631-1-git-send-email-catap@catap.ru","subject":"Re: [PATCH] http-push: support full URI in handle_remote_ls_ctx()","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2009-01-18T21:28:04Z","receivedAt":"2009-01-18T21:28:04Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"Kirill A. Korinskiy\" <catap@catap.ru> writes:\n\n> @@ -1424,9 +1425,18 @@ static void handle_remote_ls_ctx(struct xml_ctx *ctx, int tag_closed)\n>  \t\t\t\tls->userFunc(ls);\n>  \t\t\t}\n>  \t\t} else if (!strcmp(ctx->name, DAV_PROPFIND_NAME) && ctx->cdata) {\n> -\t\t\tls->dentry_name = xmalloc(strlen(ctx->cdata) -\n> +\t\t\tchar *path = ctx->cdata;\n> +\t\t\tif (!strcmp(ctx->cdata, \"http://\")) {\n> +\t\t\t\tpath = strchr(path + sizeof(\"http://\") - 1, '/');\n> +\t\t\t} else if (!strcmp(ctx->cdata, \"https://\")) {\n> +\t\t\t\tpath = strchr(path + sizeof(\"https://\") - 1, '/');\n> +\t\t\t}\n> +\n> +\t\t\tpath += remote->path_len;\n\nI see you chose to address the issue I pointed out in:\n\n    http://thread.gmane.org/gmane.comp.version-control.git/103804/focus=104363\n\nby being more strict.  That's the only change I can spot compared to\ne1f33ef (http-push: support full URI in handle_remote_ls_ctx(),\n2008-12-23) that is already in maint.\n\nCould you make this into an incremental patch?\n"}]}