From: Tay Ray Chuan <rctay89@gmail.com>
To: Git Mailing List <git@vger.kernel.org>
Cc: Junio C Hamano <gitster@pobox.com>,
Johannes Schindelin <Johannes.Schindelin@gmx.de>,
Mike Hommey <mh@glandium.org>
Subject: [PATCH 18/23] http-push.c::remote_exists(): use the new http API
Date: Sat, 6 Jun 2009 00:05:57 +0800 [thread overview]
Message-ID: <20090606000557.18c55768.rctay89@gmail.com> (raw)
From: Mike Hommey <mh@glandium.org>
Subject: [WIP Patch 08/12] Use the new http API in update_remote_info_refs()
Date: Sun, 18 Jan 2009 09:04:33 +0100
Signed-off-by: Mike Hommey <mh@glandium.org>
Signed-off-by: Tay Ray Chuan <rctay89@gmail.com>
---
http-push.c | 31 ++++++++++++-------------------
1 files changed, 12 insertions(+), 19 deletions(-)
diff --git a/http-push.c b/http-push.c
index b01db75..455e0aa 100644
--- a/http-push.c
+++ b/http-push.c
@@ -2005,29 +2005,22 @@ static void update_remote_info_refs(struct remote_lock *lock)
static int remote_exists(const char *path)
{
char *url = xmalloc(strlen(repo->url) + strlen(path) + 1);
- struct active_request_slot *slot;
- struct slot_results results;
- int ret = -1;
+ int ret;
sprintf(url, "%s%s", repo->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;
+ case HTTP_ERROR:
+ http_error(url, HTTP_ERROR);
+ default:
+ ret = -1;
}
-
free(url);
return ret;
}
--
1.6.3.1
next reply other threads:[~2009-06-05 16:09 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-06-05 16:05 Tay Ray Chuan [this message]
2009-06-05 20:54 ` [PATCH 18/23] http-push.c::remote_exists(): use the new http API Jakub Narebski
2009-06-06 1:03 ` Tay Ray Chuan
[not found] <cover.1244277116.git.rctay89@gmail.com>
2009-06-06 8:43 ` Tay Ray Chuan
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20090606000557.18c55768.rctay89@gmail.com \
--to=rctay89@gmail.com \
--cc=Johannes.Schindelin@gmx.de \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=mh@glandium.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).