Skip to content

Commit be22d92

Browse files
jrngitster
authored andcommitted
http: avoid empty error messages for some curl errors
When asked to fetch over SSL without a valid /etc/ssl/certs/ca-certificates.crt file, "git fetch" writes error: while accessing https://github.com/torvalds/linux.git/info/refs which is a little disconcerting. Better to fall back to curl_easy_strerror(result) when the error string is empty, like the curl utility does: error: Problem with the SSL CA cert (path? access rights?) while accessing https://github.com/torvalds/linux.git/info/refs Signed-off-by: Jonathan Nieder <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 8abc508 commit be22d92

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

http.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -846,8 +846,13 @@ static int http_request(const char *url, void *result, int target, int options)
846846
init_curl_http_auth(slot->curl);
847847
ret = HTTP_REAUTH;
848848
}
849-
} else
849+
} else {
850+
if (!curl_errorstr[0])
851+
strlcpy(curl_errorstr,
852+
curl_easy_strerror(results.curl_result),
853+
sizeof(curl_errorstr));
850854
ret = HTTP_ERROR;
855+
}
851856
} else {
852857
error("Unable to start HTTP request for %s", url);
853858
ret = HTTP_START_FAILED;

0 commit comments

Comments
 (0)