Skip to content

Commit 446b941

Browse files
glandiumgitster
authored andcommitted
http-push.c::remote_exists(): use the new http API
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 0d5896e commit 446b941

File tree

1 file changed

+12
-19
lines changed

1 file changed

+12
-19
lines changed

http-push.c

Lines changed: 12 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2004,29 +2004,22 @@ static void update_remote_info_refs(struct remote_lock *lock)
20042004
static int remote_exists(const char *path)
20052005
{
20062006
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;
20102008

20112009
sprintf(url, "%s%s", repo->url, path);
20122010

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;
20282022
}
2029-
20302023
free(url);
20312024
return ret;
20322025
}

0 commit comments

Comments
 (0)