提交 4dd4a09e 编写于 作者: J Junio C Hamano

Merge branch 'rc/maint-curl-helper' into maint

* rc/maint-curl-helper:
  remote-curl: ensure that URLs have a trailing slash
  http: make end_url_with_slash() public
  t5541-http-push: add test for URLs with trailing slash

Conflicts:
	remote-curl.c
......@@ -720,7 +720,7 @@ static inline int hex(int v)
return 'A' + v - 10;
}
static void end_url_with_slash(struct strbuf *buf, const char *url)
void end_url_with_slash(struct strbuf *buf, const char *url)
{
strbuf_addstr(buf, url);
if (buf->len && buf->buf[buf->len - 1] != '/')
......
......@@ -117,6 +117,7 @@ extern void append_remote_object_url(struct strbuf *buf, const char *url,
int only_two_digit_prefix);
extern char *get_remote_object_url(const char *url, const char *hex,
int only_two_digit_prefix);
extern void end_url_with_slash(struct strbuf *buf, const char *url);
/* Options for http_request_*() */
#define HTTP_NO_CACHE 1
......
......@@ -9,7 +9,7 @@
#include "sideband.h"
static struct remote *remote;
static const char *url;
static const char *url; /* always ends with a trailing slash */
struct options {
int verbosity;
......@@ -101,7 +101,7 @@ static struct discovery* discover_refs(const char *service)
return last;
free_discovery(last);
strbuf_addf(&buffer, "%s/info/refs", url);
strbuf_addf(&buffer, "%sinfo/refs", url);
if (!prefixcmp(url, "http://") || !prefixcmp(url, "https://")) {
is_http = 1;
if (!strchr(url, '?'))
......@@ -120,7 +120,7 @@ static struct discovery* discover_refs(const char *service)
strbuf_reset(&buffer);
proto_git_candidate = 0;
strbuf_addf(&buffer, "%s/info/refs", url);
strbuf_addf(&buffer, "%sinfo/refs", url);
refs_url = strbuf_detach(&buffer, NULL);
http_ret = http_get_strbuf(refs_url, &buffer, HTTP_NO_CACHE);
......@@ -509,7 +509,7 @@ static int rpc_service(struct rpc_state *rpc, struct discovery *heads)
rpc->out = client.out;
strbuf_init(&rpc->result, 0);
strbuf_addf(&buf, "%s/%s", url, svc);
strbuf_addf(&buf, "%s%s", url, svc);
rpc->service_url = strbuf_detach(&buf, NULL);
strbuf_addf(&buf, "Content-Type: application/x-%s-request", svc);
......@@ -798,11 +798,13 @@ int main(int argc, const char **argv)
remote = remote_get(argv[1]);
if (argc > 2) {
url = argv[2];
end_url_with_slash(&buf, argv[2]);
} else {
url = remote->url[0];
end_url_with_slash(&buf, remote->url[0]);
}
url = strbuf_detach(&buf, NULL);
http_init(remote);
do {
......
......@@ -34,8 +34,34 @@ test_expect_success 'setup remote repository' '
mv test_repo.git "$HTTPD_DOCUMENT_ROOT_PATH"
'
test_expect_success 'clone remote repository' '
cat >exp <<EOF
GET /smart/test_repo.git/info/refs?service=git-upload-pack HTTP/1.1 200
POST /smart/test_repo.git/git-upload-pack HTTP/1.1 200
EOF
test_expect_success 'no empty path components' '
# In the URL, add a trailing slash, and see if git appends yet another
# slash.
cd "$ROOT_PATH" &&
git clone $HTTPD_URL/smart/test_repo.git/ test_repo_clone &&
sed -e "
s/^.* \"//
s/\"//
s/ [1-9][0-9]*\$//
s/^GET /GET /
" >act <"$HTTPD_ROOT_PATH"/access.log &&
# Clear the log, so that it does not affect the "used receive-pack
# service" test which reads the log too.
#
# We do this before the actual comparison to ensure the log is cleared.
echo > "$HTTPD_ROOT_PATH"/access.log &&
test_cmp exp act
'
test_expect_success 'clone remote repository' '
rm -rf test_repo_clone &&
git clone $HTTPD_URL/smart/test_repo.git test_repo_clone
'
......@@ -68,6 +94,7 @@ test_expect_success 'create and delete remote branch' '
'
cat >exp <<EOF
GET /smart/test_repo.git/info/refs?service=git-upload-pack HTTP/1.1 200
POST /smart/test_repo.git/git-upload-pack HTTP/1.1 200
GET /smart/test_repo.git/info/refs?service=git-receive-pack HTTP/1.1 200
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册