Re: [WIP Patch 08/12] Use the new http API in update_remote_info_refs()
- From
Johannes Schindelin <johannes.schindelin@gmx.de>
- Date
- Jan 18, 2009, 15:18 UTC
- Message-ID
- <alpine.DEB.1.00.0901181615070.3586@pacific.mpi-cbg.de>
- In-Reply-To
- <1232265877-3649-9-git-send-email-mh@glandium.org>
Hi,
On Sun, 18 Jan 2009, Mike Hommey wrote:
Show 13 quoted lines
>
> Signed-off-by: Mike Hommey <mh@glandium.org>
> ---
> http-push.c | 29 ++++++++++-------------------
> 1 files changed, 10 insertions(+), 19 deletions(-)
>
> diff --git a/http-push.c b/http-push.c
> index e0b4f5a..7627860 100644
> --- a/http-push.c
> +++ b/http-push.c
> @@ -1960,29 +1960,20 @@ static void update_remote_info_refs(struct remote_lock *lock)
> static int remote_exists(const char *path)
> {Heh, I see where your commit subject comes from, but it should rather mention the function "remote_exists()"...
Show 33 quoted lines
> char *url = xmalloc(strlen(remote->url) + strlen(path) + 1);
> - struct active_request_slot *slot;
> - struct slot_results results;
> - int ret = -1;
> + int ret;
>
> sprintf(url, "%s%s", remote->url, path);
>
> - slot = get_active_slot();
> - slot->results = &results;
> - curl_easy_setopt(slot->curl, CURLOPT_URL, url);
> - curl_easy_setopt(slot->curl, CURLOPT_NOBODY, 1);
> -
> - if (start_active_slot(slot)) {
> - run_active_slot(slot);
> - if (results.http_code == 404)
> - ret = 0;
> - else if (results.curl_result == CURLE_OK)
> - ret = 1;
> - else
> - fprintf(stderr, "HEAD HTTP error %ld\n", results.http_code);
> - } else {
> - fprintf(stderr, "Unable to start HEAD request\n");
> + switch (http_get_strbuf(url, NULL, 0)) {
> + case HTTP_OK:
> + ret = 1;
> + break;
> + case HTTP_MISSING_TARGET:
> + ret = 0;
> + break;
> + default:
> + ret = -1;
> }Does http_get_strbuf() already show the error? Not as far as I can see, even if it would make sense, no? At least you'll have to "return error(...)".
Ciao, Dscho