1
0
mirror of https://github.com/git/git.git synced 2024-11-15 14:14:08 +01:00

http.c::http_fetch_ref(): use the new http API

The error message ("Unable to start request") has been removed, since
the http API already prints it.

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:
Mike Hommey 2009-06-06 16:43:55 +08:00 committed by Junio C Hamano
parent 28307b99dd
commit 0d5896e1cc

33
http.c

@ -773,34 +773,17 @@ int http_fetch_ref(const char *base, struct ref *ref)
{ {
char *url; char *url;
struct strbuf buffer = STRBUF_INIT; struct strbuf buffer = STRBUF_INIT;
struct active_request_slot *slot; int ret = -1;
struct slot_results results;
int ret;
url = quote_ref_url(base, ref->name); url = quote_ref_url(base, ref->name);
slot = get_active_slot(); if (http_get_strbuf(url, &buffer, HTTP_NO_CACHE) == HTTP_OK) {
slot->results = &results; strbuf_rtrim(&buffer);
curl_easy_setopt(slot->curl, CURLOPT_FILE, &buffer); if (buffer.len == 40)
curl_easy_setopt(slot->curl, CURLOPT_WRITEFUNCTION, fwrite_buffer); ret = get_sha1_hex(buffer.buf, ref->old_sha1);
curl_easy_setopt(slot->curl, CURLOPT_HTTPHEADER, NULL); else if (!prefixcmp(buffer.buf, "ref: ")) {
curl_easy_setopt(slot->curl, CURLOPT_URL, url); ref->symref = xstrdup(buffer.buf + 5);
if (start_active_slot(slot)) { ret = 0;
run_active_slot(slot);
if (results.curl_result == CURLE_OK) {
strbuf_rtrim(&buffer);
if (buffer.len == 40)
ret = get_sha1_hex(buffer.buf, ref->old_sha1);
else if (!prefixcmp(buffer.buf, "ref: ")) {
ref->symref = xstrdup(buffer.buf + 5);
ret = 0;
} else
ret = 1;
} else {
ret = error("Couldn't get %s for %s\n%s",
url, ref->name, curl_errorstr);
} }
} else {
ret = error("Unable to start request");
} }
strbuf_release(&buffer); strbuf_release(&buffer);