git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 3/3] Return CURL error message when object transfer fails

From
NHNick Hengeveld <nickh@reactrix.com>
Date
Sep 26, 2005, 17:52 UTC
Message-ID
<20050926175211.GD9410@reactrix.com>
Return CURL error message when object transfer fails
Signed-off-by: Nick Hengeveld <nickh@reactrix.com>
---

It might be better to extend this to all places that curl_easy_perform is called, rather than just in fetch_object.

 http-fetch.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)
330da7634e6a707779dcc8648841f501d2a47568
diff --git a/http-fetch.c b/http-fetch.c
--- a/http-fetch.c
+++ b/http-fetch.c
@@ -19,6 +19,7 @@
 static CURL *curl;
 static struct curl_slist *no_pragma_header;
 static struct curl_slist *no_range_header;
+static char curl_errorstr[CURL_ERROR_SIZE];
 
 static char *initial_base;
 
@@ -389,6 +390,7 @@ int fetch_object(struct alt_base *repo, 
 	curl_easy_setopt(curl, CURLOPT_FILE, NULL);
 	curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, fwrite_sha1_file);
 	curl_easy_setopt(curl, CURLOPT_HTTPHEADER, no_pragma_header);
+	curl_easy_setopt(curl, CURLOPT_ERRORBUFFER, curl_errorstr);
 
 	url = xmalloc(strlen(repo->base) + 50);
 	strcpy(url, repo->base);
@@ -448,7 +450,7 @@ int fetch_object(struct alt_base *repo, 
 	curl_result = curl_easy_perform(curl);
 	curl_easy_setopt(curl, CURLOPT_HTTPHEADER, no_range_header);
 	if (curl_result != 0) {
-		return -1;
+		return error(curl_errorstr);
 	}
 
 	fchmod(local, 0444);
Next: Junio C Hamano
Message 1 of 6 in “Return CURL error message when object transfer fails”
  1. 3/3 Return CURL error message when object transfer failsNick Hengeveld, Sep 26, 2005
  2. Junio C HamanoSep 26, 2005
  3. Nick HengeveldSep 27, 2005
  4. Junio C HamanoSep 27, 2005
  5. Junio C HamanoSep 27, 2005
  6. Nick HengeveldSep 27, 2005

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.