{"thread":{"id":"23368","subject":"[PATCH] remote-curl: ensure that URLs do not have a trailing slash","startedAt":"2010-04-07T14:51:32Z","lastAt":"2010-04-08T02:15:18Z","messageCount":10,"participants":["Tay Ray Chuan","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"138837","messageId":"1270651892-5712-1-git-send-email-rctay89@gmail.com","threadId":"23368","inReplyTo":null,"subject":"[PATCH] remote-curl: ensure that URLs do not have a trailing slash","fromName":"Tay Ray Chuan","fromEmail":"rctay89@gmail.com","sentAt":"2010-04-07T14:51:32Z","receivedAt":"2010-04-07T14:51:32Z","isPatch":true,"sender":{"key":"rctay89@gmail.com","avatar":"https://avatars.githubusercontent.com/u/61553?v=4"},"body":"Signed-off-by: Tay Ray Chuan <rctay89@gmail.com>\n---\n remote-curl.c |    9 ++++++---\n 1 files changed, 6 insertions(+), 3 deletions(-)\n\ndiff --git a/remote-curl.c b/remote-curl.c\nindex 0782756..0f21f8a 100644\n--- a/remote-curl.c\n+++ b/remote-curl.c\n@@ -101,7 +101,8 @@ static struct discovery* discover_refs(const char *service)\n \t\treturn last;\n \tfree_discovery(last);\n \n-\tstrbuf_addf(&buffer, \"%s/info/refs\", url);\n+\tend_url_with_slash(&buffer, url);\n+\tstrbuf_addstr(&buffer, \"info/refs\");\n \tif (!prefixcmp(url, \"http://\") || !prefixcmp(url, \"https://\")) {\n \t\tis_http = 1;\n \t\tif (!strchr(url, '?'))\n@@ -120,7 +121,8 @@ static struct discovery* discover_refs(const char *service)\n \t\tstrbuf_reset(&buffer);\n \n \t\tproto_git_candidate = 0;\n-\t\tstrbuf_addf(&buffer, \"%s/info/refs\", url);\n+\t\tend_url_with_slash(&buffer, url);\n+\t\tstrbuf_addstr(&buffer, \"info/refs\");\n \t\trefs_url = strbuf_detach(&buffer, NULL);\n \n \t\thttp_ret = http_get_strbuf(refs_url, &buffer, HTTP_NO_CACHE);\n@@ -511,7 +513,8 @@ static int rpc_service(struct rpc_state *rpc, struct discovery *heads)\n \trpc->out = client.out;\n \tstrbuf_init(&rpc->result, 0);\n \n-\tstrbuf_addf(&buf, \"%s/%s\", url, svc);\n+\tend_url_with_slash(&buf, url)\n+\tstrbuf_addf(&buf, \"%s\", svc);\n \trpc->service_url = strbuf_detach(&buf, NULL);\n \n \tstrbuf_addf(&buf, \"Content-Type: application/x-%s-request\", svc);\n-- \n1.7.0.20.gcb44ed\n"},{"id":"138843","messageId":"7viq83e1pd.fsf@alter.siamese.dyndns.org","threadId":"23368","inReplyTo":"1270651892-5712-1-git-send-email-rctay89@gmail.com","subject":"Re: [PATCH] remote-curl: ensure that URLs do not have a trailing slash","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2010-04-07T15:12:30Z","receivedAt":"2010-04-07T15:12:30Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Tay Ray Chuan <rctay89@gmail.com> writes:\n\n> Signed-off-by: Tay Ray Chuan <rctay89@gmail.com>\n> ---\n>  remote-curl.c |    9 ++++++---\n>  1 files changed, 6 insertions(+), 3 deletions(-)\n>\n> diff --git a/remote-curl.c b/remote-curl.c\n> index 0782756..0f21f8a 100644\n> --- a/remote-curl.c\n> +++ b/remote-curl.c\n> @@ -101,7 +101,8 @@ static struct discovery* discover_refs(const char *service)\n>  \t\treturn last;\n>  \tfree_discovery(last);\n>  \n> -\tstrbuf_addf(&buffer, \"%s/info/refs\", url);\n> +\tend_url_with_slash(&buffer, url);\n> +\tstrbuf_addstr(&buffer, \"info/refs\");\n>  \tif (!prefixcmp(url, \"http://\") || !prefixcmp(url, \"https://\")) {\n>  \t\tis_http = 1;\n>  \t\tif (!strchr(url, '?'))\n> @@ -120,7 +121,8 @@ static struct discovery* discover_refs(const char *service)\n>  \t\tstrbuf_reset(&buffer);\n>  \n>  \t\tproto_git_candidate = 0;\n> -\t\tstrbuf_addf(&buffer, \"%s/info/refs\", url);\n> +\t\tend_url_with_slash(&buffer, url);\n> +\t\tstrbuf_addstr(&buffer, \"info/refs\");\n>  \t\trefs_url = strbuf_detach(&buffer, NULL);\n>  \n>  \t\thttp_ret = http_get_strbuf(refs_url, &buffer, HTTP_NO_CACHE);\n> @@ -511,7 +513,8 @@ static int rpc_service(struct rpc_state *rpc, struct discovery *heads)\n>  \trpc->out = client.out;\n>  \tstrbuf_init(&rpc->result, 0);\n>  \n> -\tstrbuf_addf(&buf, \"%s/%s\", url, svc);\n> +\tend_url_with_slash(&buf, url)\n> +\tstrbuf_addf(&buf, \"%s\", svc);\n>  \trpc->service_url = strbuf_detach(&buf, NULL);\n>  \n>  \tstrbuf_addf(&buf, \"Content-Type: application/x-%s-request\", svc);\n\nThe code does not look like it is making sure things do not have a\ntrailing slash.  For example, if svc has trailing slash, either %s/%s or\nstrbuf_addf() would have the last character of svc in rpc->service_url.\n\nYou are fixing something else.\n\nThe new code avoids duplicated slashes in the middle if \"url\" can but does\nnot necessarily end with a slash.  Is that what you are trying to fix?  I\nwonder if it makes more sense to make sure \"url\" always ends with a slash\nat the calling sites where it is obtained from either the end user or from\nthe running environment...\n"},{"id":"138847","messageId":"p2ube6fef0d1004070857j874c2b60z6a4794d472b0ee8a@mail.gmail.com","threadId":"23368","inReplyTo":"7viq83e1pd.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH] remote-curl: ensure that URLs do not have a trailing slash","fromName":"Tay Ray Chuan","fromEmail":"rctay89@gmail.com","sentAt":"2010-04-07T15:57:28Z","receivedAt":"2010-04-07T15:57:28Z","isPatch":true,"sender":{"key":"rctay89@gmail.com","avatar":"https://avatars.githubusercontent.com/u/61553?v=4"},"body":"Hi,\n\nOn Wed, Apr 7, 2010 at 11:12 PM, Junio C Hamano <gitster@pobox.com> wrote:\n> The code does not look like it is making sure things do not have a\n> trailing slash.  For example, if svc has trailing slash, either %s/%s or\n> strbuf_addf() would have the last character of svc in rpc->service_url.\n>\n> You are fixing something else.\n>\n> The new code avoids duplicated slashes in the middle if \"url\" can but does\n> not necessarily end with a slash.  Is that what you are trying to fix?\n\nthe commit message is misleading, yes. I'll have another go at it.\n\n>  I\n> wonder if it makes more sense to make sure \"url\" always ends with a slash\n> at the calling sites where it is obtained from either the end user or from\n> the running environment...\n\nGood idea.\n\n-- \nCheers,\nRay Chuan\n"},{"id":"138848","messageId":"1270655917-5188-1-git-send-email-rctay89@gmail.com","threadId":"23368","inReplyTo":"p2ube6fef0d1004070857j874c2b60z6a4794d472b0ee8a@mail.gmail.com","subject":"[PATCH v2 1/2] http: make end_url_with_slash() public","fromName":"Tay Ray Chuan","fromEmail":"rctay89@gmail.com","sentAt":"2010-04-07T15:58:37Z","receivedAt":"2010-04-07T15:58:37Z","isPatch":true,"sender":{"key":"rctay89@gmail.com","avatar":"https://avatars.githubusercontent.com/u/61553?v=4"},"body":"---\n http.c |    2 +-\n http.h |    1 +\n 2 files changed, 2 insertions(+), 1 deletions(-)\n\ndiff --git a/http.c b/http.c\nindex 51253e1..07a03fd 100644\n--- a/http.c\n+++ b/http.c\n@@ -720,7 +720,7 @@ static inline int hex(int v)\n \t\treturn 'A' + v - 10;\n }\n \n-static void end_url_with_slash(struct strbuf *buf, const char *url)\n+void end_url_with_slash(struct strbuf *buf, const char *url)\n {\n \tstrbuf_addstr(buf, url);\n \tif (buf->len && buf->buf[buf->len - 1] != '/')\ndiff --git a/http.h b/http.h\nindex 2dd03e8..37a6a6a 100644\n--- a/http.h\n+++ b/http.h\n@@ -117,6 +117,7 @@ extern void append_remote_object_url(struct strbuf *buf, const char *url,\n \t\t\t\t     int only_two_digit_prefix);\n extern char *get_remote_object_url(const char *url, const char *hex,\n \t\t\t\t   int only_two_digit_prefix);\n+extern void end_url_with_slash(struct strbuf *buf, const char *url);\n \n /* Options for http_request_*() */\n #define HTTP_NO_CACHE\t\t1\n-- \n1.6.6.1368.g82eeb\n\n\n>From 38c2aba1e77591d9cd57790d9a993f59659496ae Mon Sep 17 00:00:00 2001\nFrom: Tay Ray Chuan <rctay89@gmail.com>\nDate: Wed, 7 Apr 2010 23:44:01 +0800\nSubject: [PATCH v2 2/2] remote-curl: ensure that URLs have a trailing slash\n\n---\n remote-curl.c |   16 +++++++++++-----\n 1 files changed, 11 insertions(+), 5 deletions(-)\n\ndiff --git a/remote-curl.c b/remote-curl.c\nindex 0782756..ae14137 100644\n--- a/remote-curl.c\n+++ b/remote-curl.c\n@@ -9,6 +9,10 @@\n #include \"sideband.h\"\n \n static struct remote *remote;\n+\n+/* At assignment-time, we append a trailing slash; always use this as\n+ * if it ends with a slash.\n+ */\n static const char *url;\n \n struct options {\n@@ -101,7 +105,7 @@ static struct discovery* discover_refs(const char *service)\n \t\treturn last;\n \tfree_discovery(last);\n \n-\tstrbuf_addf(&buffer, \"%s/info/refs\", url);\n+\tstrbuf_addf(&buffer, \"%sinfo/refs\", url);\n \tif (!prefixcmp(url, \"http://\") || !prefixcmp(url, \"https://\")) {\n \t\tis_http = 1;\n \t\tif (!strchr(url, '?'))\n@@ -120,7 +124,7 @@ static struct discovery* discover_refs(const char *service)\n \t\tstrbuf_reset(&buffer);\n \n \t\tproto_git_candidate = 0;\n-\t\tstrbuf_addf(&buffer, \"%s/info/refs\", url);\n+\t\tstrbuf_addf(&buffer, \"%sinfo/refs\", url);\n \t\trefs_url = strbuf_detach(&buffer, NULL);\n \n \t\thttp_ret = http_get_strbuf(refs_url, &buffer, HTTP_NO_CACHE);\n@@ -511,7 +515,7 @@ static int rpc_service(struct rpc_state *rpc, struct discovery *heads)\n \trpc->out = client.out;\n \tstrbuf_init(&rpc->result, 0);\n \n-\tstrbuf_addf(&buf, \"%s/%s\", url, svc);\n+\tstrbuf_addf(&buf, \"%s%s\", url, svc);\n \trpc->service_url = strbuf_detach(&buf, NULL);\n \n \tstrbuf_addf(&buf, \"Content-Type: application/x-%s-request\", svc);\n@@ -800,11 +804,13 @@ int main(int argc, const char **argv)\n \tremote = remote_get(argv[1]);\n \n \tif (argc > 2) {\n-\t\turl = argv[2];\n+\t\tend_url_with_slash(&buf, argv[2]);\n \t} else {\n-\t\turl = remote->url[0];\n+\t\tend_url_with_slash(&buf, remote->url[0]);\n \t}\n \n+\turl = strbuf_detach(&buf, NULL);\n+\n \thttp_init(remote);\n \n \tdo {\n-- \n1.6.6.1368.g82eeb\n"},{"id":"138849","messageId":"1270656067-688-1-git-send-email-rctay89@gmail.com","threadId":"23368","inReplyTo":"p2ube6fef0d1004070857j874c2b60z6a4794d472b0ee8a@mail.gmail.com","subject":"[PATCH v2 resend 1/2] http: make end_url_with_slash() public","fromName":"Tay Ray Chuan","fromEmail":"rctay89@gmail.com","sentAt":"2010-04-07T16:01:06Z","receivedAt":"2010-04-07T16:01:06Z","isPatch":true,"sender":{"key":"rctay89@gmail.com","avatar":"https://avatars.githubusercontent.com/u/61553?v=4"},"body":"---\n http.c |    2 +-\n http.h |    1 +\n 2 files changed, 2 insertions(+), 1 deletions(-)\n\ndiff --git a/http.c b/http.c\nindex 51253e1..07a03fd 100644\n--- a/http.c\n+++ b/http.c\n@@ -720,7 +720,7 @@ static inline int hex(int v)\n \t\treturn 'A' + v - 10;\n }\n \n-static void end_url_with_slash(struct strbuf *buf, const char *url)\n+void end_url_with_slash(struct strbuf *buf, const char *url)\n {\n \tstrbuf_addstr(buf, url);\n \tif (buf->len && buf->buf[buf->len - 1] != '/')\ndiff --git a/http.h b/http.h\nindex 2dd03e8..37a6a6a 100644\n--- a/http.h\n+++ b/http.h\n@@ -117,6 +117,7 @@ extern void append_remote_object_url(struct strbuf *buf, const char *url,\n \t\t\t\t     int only_two_digit_prefix);\n extern char *get_remote_object_url(const char *url, const char *hex,\n \t\t\t\t   int only_two_digit_prefix);\n+extern void end_url_with_slash(struct strbuf *buf, const char *url);\n \n /* Options for http_request_*() */\n #define HTTP_NO_CACHE\t\t1\n-- \n1.6.6.1368.g82eeb\n"},{"id":"138850","messageId":"1270656067-688-2-git-send-email-rctay89@gmail.com","threadId":"23368","inReplyTo":"1270656067-688-1-git-send-email-rctay89@gmail.com","subject":"[PATCH v2 resend 2/2] remote-curl: ensure that URLs have a trailing slash","fromName":"Tay Ray Chuan","fromEmail":"rctay89@gmail.com","sentAt":"2010-04-07T16:01:07Z","receivedAt":"2010-04-07T16:01:07Z","isPatch":true,"sender":{"key":"rctay89@gmail.com","avatar":"https://avatars.githubusercontent.com/u/61553?v=4"},"body":"---\n remote-curl.c |   16 +++++++++++-----\n 1 files changed, 11 insertions(+), 5 deletions(-)\n\ndiff --git a/remote-curl.c b/remote-curl.c\nindex 0782756..ae14137 100644\n--- a/remote-curl.c\n+++ b/remote-curl.c\n@@ -9,6 +9,10 @@\n #include \"sideband.h\"\n \n static struct remote *remote;\n+\n+/* At assignment-time, we append a trailing slash; always use this as\n+ * if it ends with a slash.\n+ */\n static const char *url;\n \n struct options {\n@@ -101,7 +105,7 @@ static struct discovery* discover_refs(const char *service)\n \t\treturn last;\n \tfree_discovery(last);\n \n-\tstrbuf_addf(&buffer, \"%s/info/refs\", url);\n+\tstrbuf_addf(&buffer, \"%sinfo/refs\", url);\n \tif (!prefixcmp(url, \"http://\") || !prefixcmp(url, \"https://\")) {\n \t\tis_http = 1;\n \t\tif (!strchr(url, '?'))\n@@ -120,7 +124,7 @@ static struct discovery* discover_refs(const char *service)\n \t\tstrbuf_reset(&buffer);\n \n \t\tproto_git_candidate = 0;\n-\t\tstrbuf_addf(&buffer, \"%s/info/refs\", url);\n+\t\tstrbuf_addf(&buffer, \"%sinfo/refs\", url);\n \t\trefs_url = strbuf_detach(&buffer, NULL);\n \n \t\thttp_ret = http_get_strbuf(refs_url, &buffer, HTTP_NO_CACHE);\n@@ -511,7 +515,7 @@ static int rpc_service(struct rpc_state *rpc, struct discovery *heads)\n \trpc->out = client.out;\n \tstrbuf_init(&rpc->result, 0);\n \n-\tstrbuf_addf(&buf, \"%s/%s\", url, svc);\n+\tstrbuf_addf(&buf, \"%s%s\", url, svc);\n \trpc->service_url = strbuf_detach(&buf, NULL);\n \n \tstrbuf_addf(&buf, \"Content-Type: application/x-%s-request\", svc);\n@@ -800,11 +804,13 @@ int main(int argc, const char **argv)\n \tremote = remote_get(argv[1]);\n \n \tif (argc > 2) {\n-\t\turl = argv[2];\n+\t\tend_url_with_slash(&buf, argv[2]);\n \t} else {\n-\t\turl = remote->url[0];\n+\t\tend_url_with_slash(&buf, remote->url[0]);\n \t}\n \n+\turl = strbuf_detach(&buf, NULL);\n+\n \thttp_init(remote);\n \n \tdo {\n-- \n1.6.6.1368.g82eeb\n"},{"id":"138904","messageId":"7vsk76am7s.fsf@alter.siamese.dyndns.org","threadId":"23368","inReplyTo":"1270656067-688-2-git-send-email-rctay89@gmail.com","subject":"Re: [PATCH v2 resend 2/2] remote-curl: ensure that URLs have a trailing slash","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2010-04-07T23:15:19Z","receivedAt":"2010-04-07T23:15:19Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"You didn't explain what it is for, nor sign-off this patch, but is this a\nclean-up?  Is this a bugfix?  Is this an RFC?\n"},{"id":"138912","messageId":"1270692918-4300-1-git-send-email-rctay89@gmail.com","threadId":"23368","inReplyTo":"1270656067-688-2-git-send-email-rctay89@gmail.com","subject":"[PATCH v3 1/3] t5541-http-push: add test for URLs with trailing slash","fromName":"Tay Ray Chuan","fromEmail":"rctay89@gmail.com","sentAt":"2010-04-08T02:15:16Z","receivedAt":"2010-04-08T02:15:16Z","isPatch":true,"sender":{"key":"rctay89@gmail.com","avatar":"https://avatars.githubusercontent.com/u/61553?v=4"},"body":"Signed-off-by: Tay Ray Chuan <rctay89@gmail.com>\n---\n t/t5541-http-push.sh |   29 ++++++++++++++++++++++++++++-\n 1 files changed, 28 insertions(+), 1 deletions(-)\n\ndiff --git a/t/t5541-http-push.sh b/t/t5541-http-push.sh\nindex 795dc2b..e94ac78 100755\n--- a/t/t5541-http-push.sh\n+++ b/t/t5541-http-push.sh\n@@ -34,8 +34,34 @@ test_expect_success 'setup remote repository' '\n \tmv test_repo.git \"$HTTPD_DOCUMENT_ROOT_PATH\"\n '\n \n-test_expect_success 'clone remote repository' '\n+cat >exp <<EOF\n+GET  /smart/test_repo.git/info/refs?service=git-upload-pack HTTP/1.1 200\n+POST /smart/test_repo.git/git-upload-pack HTTP/1.1 200\n+EOF\n+test_expect_failure 'no empty path components' '\n+\t# In the URL, add a trailing slash, and see if git appends yet another\n+\t# slash.\n \tcd \"$ROOT_PATH\" &&\n+\tgit clone $HTTPD_URL/smart/test_repo.git/ test_repo_clone &&\n+\n+\tsed -e \"\n+\t\ts/^.* \\\"//\n+\t\ts/\\\"//\n+\t\ts/ [1-9][0-9]*\\$//\n+\t\ts/^GET /GET  /\n+\t\" >act <\"$HTTPD_ROOT_PATH\"/access.log &&\n+\n+\t# Clear the log, so that it does not affect the \"used receive-pack\n+\t# service\" test which reads the log too.\n+\t#\n+\t# We do this before the actual comparison to ensure the log is cleared.\n+\techo > \"$HTTPD_ROOT_PATH\"/access.log &&\n+\n+\ttest_cmp exp act\n+'\n+\n+test_expect_success 'clone remote repository' '\n+\trm -rf test_repo_clone &&\n \tgit clone $HTTPD_URL/smart/test_repo.git test_repo_clone\n '\n \n@@ -68,6 +94,7 @@ test_expect_success 'create and delete remote branch' '\n '\n \n cat >exp <<EOF\n+\n GET  /smart/test_repo.git/info/refs?service=git-upload-pack HTTP/1.1 200\n POST /smart/test_repo.git/git-upload-pack HTTP/1.1 200\n GET  /smart/test_repo.git/info/refs?service=git-receive-pack HTTP/1.1 200\n-- \n1.6.6.1368.g82eeb\n"},{"id":"138914","messageId":"1270692918-4300-2-git-send-email-rctay89@gmail.com","threadId":"23368","inReplyTo":"1270692918-4300-1-git-send-email-rctay89@gmail.com","subject":"[PATCH v3 2/3] http: make end_url_with_slash() public","fromName":"Tay Ray Chuan","fromEmail":"rctay89@gmail.com","sentAt":"2010-04-08T02:15:17Z","receivedAt":"2010-04-08T02:15:17Z","isPatch":true,"sender":{"key":"rctay89@gmail.com","avatar":"https://avatars.githubusercontent.com/u/61553?v=4"},"body":"Signed-off-by: Tay Ray Chuan <rctay89@gmail.com>\n---\n http.c |    2 +-\n http.h |    1 +\n 2 files changed, 2 insertions(+), 1 deletions(-)\n\ndiff --git a/http.c b/http.c\nindex 51253e1..07a03fd 100644\n--- a/http.c\n+++ b/http.c\n@@ -720,7 +720,7 @@ static inline int hex(int v)\n \t\treturn 'A' + v - 10;\n }\n \n-static void end_url_with_slash(struct strbuf *buf, const char *url)\n+void end_url_with_slash(struct strbuf *buf, const char *url)\n {\n \tstrbuf_addstr(buf, url);\n \tif (buf->len && buf->buf[buf->len - 1] != '/')\ndiff --git a/http.h b/http.h\nindex 2dd03e8..37a6a6a 100644\n--- a/http.h\n+++ b/http.h\n@@ -117,6 +117,7 @@ extern void append_remote_object_url(struct strbuf *buf, const char *url,\n \t\t\t\t     int only_two_digit_prefix);\n extern char *get_remote_object_url(const char *url, const char *hex,\n \t\t\t\t   int only_two_digit_prefix);\n+extern void end_url_with_slash(struct strbuf *buf, const char *url);\n \n /* Options for http_request_*() */\n #define HTTP_NO_CACHE\t\t1\n-- \n1.6.6.1368.g82eeb\n"},{"id":"138913","messageId":"1270692918-4300-3-git-send-email-rctay89@gmail.com","threadId":"23368","inReplyTo":"1270692918-4300-2-git-send-email-rctay89@gmail.com","subject":"[PATCH v3 3/3] remote-curl: ensure that URLs have a trailing slash","fromName":"Tay Ray Chuan","fromEmail":"rctay89@gmail.com","sentAt":"2010-04-08T02:15:18Z","receivedAt":"2010-04-08T02:15:18Z","isPatch":true,"sender":{"key":"rctay89@gmail.com","avatar":"https://avatars.githubusercontent.com/u/61553?v=4"},"body":"Previously, we blindly assumed that URLs passed to the remote-curl\nhelper did not end with a trailing slash.\n\nUse the convenience function end_url_with_slash() from http.[ch] to\nensure that URLs have a trailing slash on invocation of the remote-curl\nhelper, and use the URL as one with a trailing slash throughout.\n\nIt is possible for users to pass a URL with a trailing slash to\nremote-curl, by, say, setting it in remote.<name>.url in their git\nconfig. The resulting requests have an empty path component (//) and may\nbreak implementations of the http git protocol.\n\nSigned-off-by: Tay Ray Chuan <rctay89@gmail.com>\n---\n remote-curl.c        |   16 +++++++++++-----\n t/t5541-http-push.sh |    2 +-\n 2 files changed, 12 insertions(+), 6 deletions(-)\n\ndiff --git a/remote-curl.c b/remote-curl.c\nindex 0782756..ae14137 100644\n--- a/remote-curl.c\n+++ b/remote-curl.c\n@@ -9,6 +9,10 @@\n #include \"sideband.h\"\n \n static struct remote *remote;\n+\n+/* At assignment-time, we append a trailing slash; always use this as\n+ * if it ends with a slash.\n+ */\n static const char *url;\n \n struct options {\n@@ -101,7 +105,7 @@ static struct discovery* discover_refs(const char *service)\n \t\treturn last;\n \tfree_discovery(last);\n \n-\tstrbuf_addf(&buffer, \"%s/info/refs\", url);\n+\tstrbuf_addf(&buffer, \"%sinfo/refs\", url);\n \tif (!prefixcmp(url, \"http://\") || !prefixcmp(url, \"https://\")) {\n \t\tis_http = 1;\n \t\tif (!strchr(url, '?'))\n@@ -120,7 +124,7 @@ static struct discovery* discover_refs(const char *service)\n \t\tstrbuf_reset(&buffer);\n \n \t\tproto_git_candidate = 0;\n-\t\tstrbuf_addf(&buffer, \"%s/info/refs\", url);\n+\t\tstrbuf_addf(&buffer, \"%sinfo/refs\", url);\n \t\trefs_url = strbuf_detach(&buffer, NULL);\n \n \t\thttp_ret = http_get_strbuf(refs_url, &buffer, HTTP_NO_CACHE);\n@@ -511,7 +515,7 @@ static int rpc_service(struct rpc_state *rpc, struct discovery *heads)\n \trpc->out = client.out;\n \tstrbuf_init(&rpc->result, 0);\n \n-\tstrbuf_addf(&buf, \"%s/%s\", url, svc);\n+\tstrbuf_addf(&buf, \"%s%s\", url, svc);\n \trpc->service_url = strbuf_detach(&buf, NULL);\n \n \tstrbuf_addf(&buf, \"Content-Type: application/x-%s-request\", svc);\n@@ -800,11 +804,13 @@ int main(int argc, const char **argv)\n \tremote = remote_get(argv[1]);\n \n \tif (argc > 2) {\n-\t\turl = argv[2];\n+\t\tend_url_with_slash(&buf, argv[2]);\n \t} else {\n-\t\turl = remote->url[0];\n+\t\tend_url_with_slash(&buf, remote->url[0]);\n \t}\n \n+\turl = strbuf_detach(&buf, NULL);\n+\n \thttp_init(remote);\n \n \tdo {\ndiff --git a/t/t5541-http-push.sh b/t/t5541-http-push.sh\nindex e94ac78..17e1bdc 100755\n--- a/t/t5541-http-push.sh\n+++ b/t/t5541-http-push.sh\n@@ -38,7 +38,7 @@ cat >exp <<EOF\n GET  /smart/test_repo.git/info/refs?service=git-upload-pack HTTP/1.1 200\n POST /smart/test_repo.git/git-upload-pack HTTP/1.1 200\n EOF\n-test_expect_failure 'no empty path components' '\n+test_expect_success 'no empty path components' '\n \t# In the URL, add a trailing slash, and see if git appends yet another\n \t# slash.\n \tcd \"$ROOT_PATH\" &&\n-- \n1.6.6.1368.g82eeb\n"}]}