@matheusbsbs / matheus-bagliano / commits / 446b941a57
Fork 0

http-push.c::remote_exists(): use the new http API

Signed-off-by: Mike Hommey <mh@glandium.org> Signed-off-by: Tay Ray Chuan <rctay89@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Mike Hommey committed Jun 6, 2009 at 16:43 UTC 446b941a57d96e0c02375534b6b3f6816e7364e5
1 file changed +12 -19
http-push.c
+12 -19
@@ -2004,29 +2004,22 @@ static void update_remote_info_refs(struct remote_lock *lock)
2004 static int remote_exists(const char *path)
2005 {
2006 char *url = xmalloc(strlen(repo->url) + strlen(path) + 1);
2007 - struct active_request_slot *slot;
2008 - struct slot_results results;
2009 - int ret = -1;
2007 + int ret;
2008
2009 sprintf(url, "%s%s", repo->url, path);
2010
2013 - slot = get_active_slot();
2014 - slot->results = &results;
2015 - curl_easy_setopt(slot->curl, CURLOPT_URL, url);
2016 - curl_easy_setopt(slot->curl, CURLOPT_NOBODY, 1);
2017 -
2018 - if (start_active_slot(slot)) {
2019 - run_active_slot(slot);
2020 - if (results.http_code == 404)
2021 - ret = 0;
2022 - else if (results.curl_result == CURLE_OK)
2023 - ret = 1;
2024 - else
2025 - fprintf(stderr, "HEAD HTTP error %ld\n", results.http_code);
2026 - } else {
2027 - fprintf(stderr, "Unable to start HEAD request\n");
2011 + switch (http_get_strbuf(url, NULL, 0)) {
2012 + case HTTP_OK:
2013 + ret = 1;
2014 + break;
2015 + case HTTP_MISSING_TARGET:
2016 + ret = 0;
2017 + break;
2018 + case HTTP_ERROR:
2019 + http_error(url, HTTP_ERROR);
2020 + default:
2021 + ret = -1;
2022 }
2029 -
2023 free(url);
2024 return ret;
2025 }