Skip to content

Commit 0d5896e

Browse files
glandiumgitster
authored andcommitted
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 <[email protected]> Signed-off-by: Tay Ray Chuan <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 28307b9 commit 0d5896e

File tree

1 file changed

+8
-25
lines changed

1 file changed

+8
-25
lines changed

http.c

Lines changed: 8 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -773,34 +773,17 @@ int http_fetch_ref(const char *base, struct ref *ref)
773773
{
774774
char *url;
775775
struct strbuf buffer = STRBUF_INIT;
776-
struct active_request_slot *slot;
777-
struct slot_results results;
778-
int ret;
776+
int ret = -1;
779777

780778
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;
801786
}
802-
} else {
803-
ret = error("Unable to start request");
804787
}
805788

806789
strbuf_release(&buffer);

0 commit comments

Comments
 (0)