@matheusbsbs / matheus-bagliano / commits / 0d5896e1cc
Fork 0

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>

Mike Hommey committed Jun 6, 2009 at 16:43 UTC 0d5896e1cc1cb6145526b6786c7720cfe8231709
1 file changed +8 -25
http.c
+8 -25
@@ -773,34 +773,17 @@ int http_fetch_ref(const char *base, struct ref *ref)
773 {
774 char *url;
775 struct strbuf buffer = STRBUF_INIT;
776 - struct active_request_slot *slot;
777 - struct slot_results results;
778 - int ret;
776 + int ret = -1;
777
778 url = quote_ref_url(base, ref->name);
781 - slot = get_active_slot();
782 - slot->results = &results;
783 - curl_easy_setopt(slot->curl, CURLOPT_FILE, &buffer);
784 - curl_easy_setopt(slot->curl, CURLOPT_WRITEFUNCTION, fwrite_buffer);
785 - curl_easy_setopt(slot->curl, CURLOPT_HTTPHEADER, NULL);
786 - curl_easy_setopt(slot->curl, CURLOPT_URL, url);
787 - if (start_active_slot(slot)) {
788 - run_active_slot(slot);
789 - if (results.curl_result == CURLE_OK) {
790 - strbuf_rtrim(&buffer);
791 - if (buffer.len == 40)
792 - ret = get_sha1_hex(buffer.buf, ref->old_sha1);
793 - else if (!prefixcmp(buffer.buf, "ref: ")) {
794 - ref->symref = xstrdup(buffer.buf + 5);
795 - ret = 0;
796 - } else
797 - ret = 1;
798 - } else {
799 - ret = error("Couldn't get %s for %s\n%s",
800 - url, ref->name, curl_errorstr);
779 + if (http_get_strbuf(url, &buffer, HTTP_NO_CACHE) == HTTP_OK) {
780 + strbuf_rtrim(&buffer);
781 + if (buffer.len == 40)
782 + ret = get_sha1_hex(buffer.buf, ref->old_sha1);
783 + else if (!prefixcmp(buffer.buf, "ref: ")) {
784 + ref->symref = xstrdup(buffer.buf + 5);
785 + ret = 0;
786 }
802 - } else {
803 - ret = error("Unable to start request");
787 }
788
789 strbuf_release(&buffer);