{"thread":{"id":"19590","subject":"[PATCH 11/17] http.c::http_fetch_ref(): use the new http API","startedAt":"2009-05-29T17:59:25Z","lastAt":"2009-05-29T17:59:25Z","messageCount":1,"participants":["Tay Ray Chuan"],"isPatch":true,"patchVersion":1,"patchTotal":17},"messages":[{"id":"115032","messageId":"20090530015925.e329cdd7.rctay89@gmail.com","threadId":"19590","inReplyTo":null,"subject":"[PATCH 11/17] http.c::http_fetch_ref(): use the new http API","fromName":"Tay Ray Chuan","fromEmail":"rctay89@gmail.com","sentAt":"2009-05-29T17:59:25Z","receivedAt":"2009-05-29T17:59:25Z","isPatch":true,"sender":{"key":"rctay89@gmail.com","avatar":"https://avatars.githubusercontent.com/u/61553?v=4"},"body":"From:\tMike Hommey <mh@glandium.org>\nSubject: [WIP Patch 04/12] Use the new http API in http_fetch_ref()\nDate:\tSun, 18 Jan 2009 09:04:29 +0100\n\nThe error message (\"Unable to start request\") has been removed, since\nthe http API already prints it.\n\nSigned-off-by: Mike Hommey <mh@glandium.org>\nSigned-off-by: Tay Ray Chuan <rctay89@gmail.com>\n---\n http.c |   33 ++++++++-------------------------\n 1 files changed, 8 insertions(+), 25 deletions(-)\n\ndiff --git a/http.c b/http.c\nindex 1434603..c640510 100644\n--- a/http.c\n+++ b/http.c\n@@ -772,34 +772,17 @@ int http_fetch_ref(const char *base, struct ref *ref)\n {\n \tchar *url;\n \tstruct strbuf buffer = STRBUF_INIT;\n-\tstruct active_request_slot *slot;\n-\tstruct slot_results results;\n-\tint ret;\n+\tint ret = -1;\n\n \turl = quote_ref_url(base, ref->name);\n-\tslot = get_active_slot();\n-\tslot->results = &results;\n-\tcurl_easy_setopt(slot->curl, CURLOPT_FILE, &buffer);\n-\tcurl_easy_setopt(slot->curl, CURLOPT_WRITEFUNCTION, fwrite_buffer);\n-\tcurl_easy_setopt(slot->curl, CURLOPT_HTTPHEADER, NULL);\n-\tcurl_easy_setopt(slot->curl, CURLOPT_URL, url);\n-\tif (start_active_slot(slot)) {\n-\t\trun_active_slot(slot);\n-\t\tif (results.curl_result == CURLE_OK) {\n-\t\t\tstrbuf_rtrim(&buffer);\n-\t\t\tif (buffer.len == 40)\n-\t\t\t\tret = get_sha1_hex(buffer.buf, ref->old_sha1);\n-\t\t\telse if (!prefixcmp(buffer.buf, \"ref: \")) {\n-\t\t\t\tref->symref = xstrdup(buffer.buf + 5);\n-\t\t\t\tret = 0;\n-\t\t\t} else\n-\t\t\t\tret = 1;\n-\t\t} else {\n-\t\t\tret = error(\"Couldn't get %s for %s\\n%s\",\n-\t\t\t\t    url, ref->name, curl_errorstr);\n+\tif (http_get_strbuf(url, &buffer, HTTP_NO_CACHE) == HTTP_OK) {\n+\t\tstrbuf_rtrim(&buffer);\n+\t\tif (buffer.len == 40)\n+\t\t\tret = get_sha1_hex(buffer.buf, ref->old_sha1);\n+\t\telse if (!prefixcmp(buffer.buf, \"ref: \")) {\n+\t\t\tref->symref = xstrdup(buffer.buf + 5);\n+\t\t\tret = 0;\n \t\t}\n-\t} else {\n-\t\tret = error(\"Unable to start request\");\n \t}\n\n \tstrbuf_release(&buffer);\n--\n1.6.3.1\n"}]}