Skip to content

Commit 3d10f72

Browse files
peffgitster
authored andcommitted
http: use normalize_curl_result() instead of manual conversion
When we switched off CURLOPT_FAILONERROR in 17966c0 (http: avoid disconnecting on 404s for loose objects, 2016-07-11), the fetch_object() function started manually handling 404's. Since we now have normalize_curl_result() for use elsewhere, we can use it here as well, shortening the code. Note that we lose the check for http/https in the URL here. None of the other result-normalizing code paths bother with this. Looking at missing_target(), which checks specifically for an FTP-specific CURLcode and "http" code 550, it seems likely that git-over-ftp has been subtly broken since 17966c0. This patch does nothing to fix that, but nor should it make anything worse (in fact, it may be slightly better because we'll actually recognize an error as such, rather than assuming CURLE_OK means we actually got some data). Signed-off-by: Jeff King <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent ccbbd8b commit 3d10f72

File tree

1 file changed

+2
-11
lines changed

1 file changed

+2
-11
lines changed

http-walker.c

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -526,17 +526,8 @@ static int fetch_object(struct walker *walker, unsigned char *sha1)
526526
req->localfile = -1;
527527
}
528528

529-
/*
530-
* we turned off CURLOPT_FAILONERROR to avoid losing a
531-
* persistent connection and got CURLE_OK.
532-
*/
533-
if (req->http_code >= 300 && req->curl_result == CURLE_OK &&
534-
(starts_with(req->url, "http://") ||
535-
starts_with(req->url, "https://"))) {
536-
req->curl_result = CURLE_HTTP_RETURNED_ERROR;
537-
xsnprintf(req->errorstr, sizeof(req->errorstr),
538-
"HTTP request failed");
539-
}
529+
normalize_curl_result(&req->curl_result, req->http_code,
530+
req->errorstr, sizeof(req->errorstr));
540531

541532
if (obj_req->state == ABORTED) {
542533
ret = error("Request for %s aborted", hex);

0 commit comments

Comments
 (0)