Subject: Re: [PATCH 17/23] http.c::http_fetch_ref(): use the new http API

From: Jakub Narebski <[email-masked]>
Date: Fri, 05 Jun 2009 13:50:58 -0700 (PDT)

Tay Ray Chuan <[email-masked]> writes:

> From:	Mike Hommey <[email-masked]>
> Subject: [WIP Patch 04/12] Use the new http API in http_fetch_ref()

What is the subject of this patch:
  "http.c::http_fetch_ref(): use the new http API"
or
  "Use the new http API in http_fetch_ref()"

Perhaps this and previous patch should be squashed?

> Date:	Sun, 18 Jan 2009 09:04:29 +0100
> 
> The error message ("Unable to start request") has been removed, since
> the http API already prints it.
> 
> Signed-off-by: Mike Hommey <[email-masked]>
> Signed-off-by: Tay Ray Chuan <[email-masked]>
> ---
>  http.c |   33 ++++++++-------------------------
>  1 files changed, 8 insertions(+), 25 deletions(-)
> 
> diff --git a/http.c b/http.c
> index df22180..2a49372 100644
> --- a/http.c
> +++ b/http.c
> @@ -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);
> --
> 1.6.3.1
> 

-- 
Jakub Narebski
Poland
ShadeHawk on #git