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

[PATCH] Fail properly when cloning from invalid HTTP URL

From
pasky@suse.cz <pasky@suse.cz>
Date
Aug 7, 2008, 00:06 UTC
Message-ID
<1218067590-31590-1-git-send-email-pasky@suse.cz>
From: Petr Baudis <pasky@suse.cz>

Currently, when cloning from invalid HTTP URL, git clone will possibly return curl error, then a confusing message about remote HEAD and then return success and leave an empty repository behind, confusing either the end-user or the automated service calling it (think repo.or.cz).

This patch changes the error() calls in get_refs_via_curl() to die()s, akin to the other get_refs_*() functions.

Cc: Daniel Barkalow <barkalow@iabervon.org>
Signed-off-by: Petr Baudis <pasky@suse.cz>
---
 transport.c |    7 +++----
 1 files changed, 3 insertions(+), 4 deletions(-)
diff --git a/transport.c b/transport.c
index 6eb65b8..b88b89b 100644
--- a/transport.c
+++ b/transport.c
@@ -464,16 +464,15 @@ static struct ref *get_refs_via_curl(struct transport *transport)
 		if (results.curl_result != CURLE_OK) {
 			strbuf_release(&buffer);
 			if (missing_target(&results)) {
+				die("%s not found: did you run git update-server-info on the server?", refs_url);
 				return NULL;
 			} else {
-				error("%s", curl_errorstr);
-				return NULL;
+				die("%s download error - %s", refs_url, curl_errorstr);
 			}
 		}
 	} else {
 		strbuf_release(&buffer);
-		error("Unable to start request");
-		return NULL;
+		die("Unable to start HTTP request");
 	}
 
 	data = buffer.buf;
-- 
1.5.6.3.392.g292f1
Next: Junio C Hamano
Message 1 of 3 in “Fail properly when cloning from invalid HTTP URL”
  1. Fail properly when cloning from invalid HTTP URLpasky@suse.cz, Aug 7, 2008
  2. Junio C HamanoAug 7, 2008
  3. Daniel BarkalowAug 7, 2008

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.