From: Jonathan Nieder <jrnieder@gmail.com>
To: git@vger.kernel.org
Cc: Tay Ray Chuan <rctay89@gmail.com>
Subject: [RFC/PATCH git] http: avoid empty error messages for some curl errors
Date: Mon, 5 Sep 2011 17:22:02 -0500 [thread overview]
Message-ID: <20110905222202.GA32071@elie> (raw)
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>
---
Hi,
I ran into this error today because this machine has no certs enabled.
I'm not thrilled with the following patch because the error string
buffer is not cleared very often so it seems possible for it to be
not empty but stale at the relevant moment. I would be happier if we
could rely on libcurl always filling the error buffer on errors.
What do you think?
Jonathan
http.c | 7 ++++++-
1 files changed, 6 insertions(+), 1 deletions(-)
diff --git a/http.c b/http.c
index a59cac45..dec3c60a 100644
--- a/http.c
+++ b/http.c
@@ -851,8 +851,13 @@ static int http_request(const char *url, void *result, int target, int options)
init_curl_http_auth(slot->curl);
ret = HTTP_REAUTH;
}
- } else
+ } else {
+ if (!curl_errorstr[0])
+ strlcpy(curl_errorstr,
+ curl_easy_strerror(results.curl_result),
+ sizeof(curl_errorstr));
ret = HTTP_ERROR;
+ }
} else {
error("Unable to start HTTP request for %s", url);
ret = HTTP_START_FAILED;
--
1.7.6
next reply other threads:[~2011-09-05 22:22 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-09-05 22:22 Jonathan Nieder [this message]
2011-09-05 22:29 ` [PATCH] http: remove extra newline in error message Jonathan Nieder
2011-09-06 12:20 ` [RFC/PATCH git] http: avoid empty error messages for some curl errors Daniel Stenberg
2011-09-06 17:02 ` Junio C Hamano
2011-09-06 18:00 ` Daniel Stenberg
2011-09-06 22:49 ` Junio C Hamano
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20110905222202.GA32071@elie \
--to=jrnieder@gmail.com \
--cc=git@vger.kernel.org \
--cc=rctay89@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).