diff options
author | Mike Hommey <mh@glandium.org> | 2009-06-06 16:43:55 +0800 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2009-06-06 11:03:10 -0700 |
commit | 0d5896e1cc1cb6145526b6786c7720cfe8231709 (patch) | |
tree | 08a95a1b5d42a1ecbfba8fef78a811d9adb4576a /http.c | |
parent | 28307b99ddb8e7284793d5ec830af10f130fa287 (diff) | |
download | git-0d5896e1cc1cb6145526b6786c7720cfe8231709.tar.gz |
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>
Diffstat (limited to 'http.c')
-rw-r--r-- | http.c | 33 |
1 files changed, 8 insertions, 25 deletions
@@ -773,34 +773,17 @@ int http_fetch_ref(const char *base, struct ref *ref) { char *url; struct strbuf buffer = STRBUF_INIT; - struct active_request_slot *slot; - struct slot_results results; - int ret; + int ret = -1; url = quote_ref_url(base, ref->name); - slot = get_active_slot(); - slot->results = &results; - curl_easy_setopt(slot->curl, CURLOPT_FILE, &buffer); - curl_easy_setopt(slot->curl, CURLOPT_WRITEFUNCTION, fwrite_buffer); - curl_easy_setopt(slot->curl, CURLOPT_HTTPHEADER, NULL); - curl_easy_setopt(slot->curl, CURLOPT_URL, url); - if (start_active_slot(slot)) { - 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); + if (http_get_strbuf(url, &buffer, HTTP_NO_CACHE) == HTTP_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 = error("Unable to start request"); } strbuf_release(&buffer); |