mirror of
https://github.com/git/git
synced 2024-09-12 21:04:12 +00:00
transport.c::get_refs_via_curl(): use the new http API
Signed-off-by: Mike Hommey <mh@glandium.org> Signed-off-by: Tay Ray Chuan <rctay89@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
parent
e929cd20bb
commit
28307b99dd
34
transport.c
34
transport.c
|
@ -439,9 +439,7 @@ static struct ref *get_refs_via_curl(struct transport *transport, int for_push)
|
||||||
char *ref_name;
|
char *ref_name;
|
||||||
char *refs_url;
|
char *refs_url;
|
||||||
int i = 0;
|
int i = 0;
|
||||||
|
int http_ret;
|
||||||
struct active_request_slot *slot;
|
|
||||||
struct slot_results results;
|
|
||||||
|
|
||||||
struct ref *refs = NULL;
|
struct ref *refs = NULL;
|
||||||
struct ref *ref = NULL;
|
struct ref *ref = NULL;
|
||||||
|
@ -461,25 +459,16 @@ static struct ref *get_refs_via_curl(struct transport *transport, int for_push)
|
||||||
refs_url = xmalloc(strlen(transport->url) + 11);
|
refs_url = xmalloc(strlen(transport->url) + 11);
|
||||||
sprintf(refs_url, "%s/info/refs", transport->url);
|
sprintf(refs_url, "%s/info/refs", transport->url);
|
||||||
|
|
||||||
slot = get_active_slot();
|
http_ret = http_get_strbuf(refs_url, &buffer, HTTP_NO_CACHE);
|
||||||
slot->results = &results;
|
switch (http_ret) {
|
||||||
curl_easy_setopt(slot->curl, CURLOPT_FILE, &buffer);
|
case HTTP_OK:
|
||||||
curl_easy_setopt(slot->curl, CURLOPT_WRITEFUNCTION, fwrite_buffer);
|
break;
|
||||||
curl_easy_setopt(slot->curl, CURLOPT_URL, refs_url);
|
case HTTP_MISSING_TARGET:
|
||||||
curl_easy_setopt(slot->curl, CURLOPT_HTTPHEADER, NULL);
|
die("%s not found: did you run git update-server-info on the"
|
||||||
|
" server?", refs_url);
|
||||||
if (start_active_slot(slot)) {
|
default:
|
||||||
run_active_slot(slot);
|
http_error(refs_url, http_ret);
|
||||||
if (results.curl_result != CURLE_OK) {
|
die("HTTP request failed");
|
||||||
strbuf_release(&buffer);
|
|
||||||
if (missing_target(&results))
|
|
||||||
die("%s not found: did you run git update-server-info on the server?", refs_url);
|
|
||||||
else
|
|
||||||
die("%s download error - %s", refs_url, curl_errorstr);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
strbuf_release(&buffer);
|
|
||||||
die("Unable to start HTTP request");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
data = buffer.buf;
|
data = buffer.buf;
|
||||||
|
@ -519,6 +508,7 @@ static struct ref *get_refs_via_curl(struct transport *transport, int for_push)
|
||||||
free(ref);
|
free(ref);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
strbuf_release(&buffer);
|
||||||
free(refs_url);
|
free(refs_url);
|
||||||
return refs;
|
return refs;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue