1
0
Fork 0
mirror of https://github.com/git/git.git synced 2024-10-28 12:59:41 +01:00

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 <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Jonathan Nieder 2011-09-05 17:22:02 -05:00 committed by Junio C Hamano
parent 8abc508222
commit be22d92eac

7
http.c
View file

@ -846,8 +846,13 @@ static int http_request(const char *url, void *result, int target, int options)
init_curl_http_auth(slot->curl); init_curl_http_auth(slot->curl);
ret = HTTP_REAUTH; ret = HTTP_REAUTH;
} }
} else } else {
if (!curl_errorstr[0])
strlcpy(curl_errorstr,
curl_easy_strerror(results.curl_result),
sizeof(curl_errorstr));
ret = HTTP_ERROR; ret = HTTP_ERROR;
}
} else { } else {
error("Unable to start HTTP request for %s", url); error("Unable to start HTTP request for %s", url);
ret = HTTP_START_FAILED; ret = HTTP_START_FAILED;