[PATCH] Fail properly when cloning from invalid HTTP URL

Subsystems: the rest

DORMANTno replies

2 messages, 2 authors, 2016-06-15 · open the first message on its own page

[PATCH] Fail properly when cloning from invalid HTTP URL

From: <hidden>
Date: 2016-06-15 22:45:07

From: Petr Baudis <redacted>

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 <redacted>
Signed-off-by: Petr Baudis <redacted>
---
 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

Re: [PATCH] Fail properly when cloning from invalid HTTP URL

From: Daniel Barkalow <hidden>
Date: 2016-06-15 22:45:07

On Thu, 7 Aug 2008, pasky@suse.cz wrote:
quoted hunk
From: Petr Baudis <redacted>

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 <redacted>
Signed-off-by: Petr Baudis <redacted>
---
 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;
The "return NULL" isn't necessary any more. Otherwise,

Acked-by: Daniel Barkalow <redacted>
 			} 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

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help