X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=remote-curl.c;h=d38812085151b6738e7ca95be10968b973bf13b4;hb=7d182f52f1a754bdccb2e7c7cea54f773f76bc5c;hp=136100695994049f2e9d6357cb25dd5a9d73ae28;hpb=e98f80f50bf9b78aab8cea6184fd708259d0c3b3;p=git.git diff --git a/remote-curl.c b/remote-curl.c index 136100695..d38812085 100644 --- a/remote-curl.c +++ b/remote-curl.c @@ -102,7 +102,7 @@ static struct discovery* discover_refs(const char *service) struct strbuf buffer = STRBUF_INIT; struct discovery *last = last_discovery; char *refs_url; - int http_ret, is_http = 0; + int http_ret, is_http = 0, proto_git_candidate = 1; if (last && !strcmp(service, last->service)) return last; @@ -121,6 +121,19 @@ static struct discovery* discover_refs(const char *service) init_walker(); http_ret = http_get_strbuf(refs_url, &buffer, HTTP_NO_CACHE); + + /* try again with "plain" url (no ? or & appended) */ + if (http_ret != HTTP_OK) { + free(refs_url); + strbuf_reset(&buffer); + + proto_git_candidate = 0; + strbuf_addf(&buffer, "%s/info/refs", url); + refs_url = strbuf_detach(&buffer, NULL); + + http_ret = http_get_strbuf(refs_url, &buffer, HTTP_NO_CACHE); + } + switch (http_ret) { case HTTP_OK: break; @@ -137,7 +150,8 @@ static struct discovery* discover_refs(const char *service) last->buf_alloc = strbuf_detach(&buffer, &last->len); last->buf = last->buf_alloc; - if (is_http && 5 <= last->len && last->buf[4] == '#') { + if (is_http && proto_git_candidate + && 5 <= last->len && last->buf[4] == '#') { /* smart HTTP response; validate that the service * pkt-line matches our request. */ @@ -170,13 +184,13 @@ static struct discovery* discover_refs(const char *service) return last; } -static int write_discovery(int fd, void *data) +static int write_discovery(int in, int out, void *data) { struct discovery *heads = data; int err = 0; - if (write_in_full(fd, heads->buf, heads->len) != heads->len) + if (write_in_full(out, heads->buf, heads->len) != heads->len) err = 1; - close(fd); + close(out); return err; } @@ -188,6 +202,7 @@ static struct ref *parse_git_refs(struct discovery *heads) memset(&async, 0, sizeof(async)); async.proc = write_discovery; async.data = heads; + async.out = -1; if (start_async(&async)) die("cannot start thread to parse advertised refs");