Skip to content

Commit fd35e42

Browse files
Petr Baudisgitster
authored andcommitted
Fail properly when cloning from invalid HTTP URL
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> Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent 781c183 commit fd35e42

1 file changed

Lines changed: 5 additions & 8 deletions

File tree

transport.c

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -463,17 +463,14 @@ static struct ref *get_refs_via_curl(struct transport *transport)
463463
run_active_slot(slot);
464464
if (results.curl_result != CURLE_OK) {
465465
strbuf_release(&buffer);
466-
if (missing_target(&results)) {
467-
return NULL;
468-
} else {
469-
error("%s", curl_errorstr);
470-
return NULL;
471-
}
466+
if (missing_target(&results))
467+
die("%s not found: did you run git update-server-info on the server?", refs_url);
468+
else
469+
die("%s download error - %s", refs_url, curl_errorstr);
472470
}
473471
} else {
474472
strbuf_release(&buffer);
475-
error("Unable to start request");
476-
return NULL;
473+
die("Unable to start HTTP request");
477474
}
478475

479476
data = buffer.buf;

0 commit comments

Comments
 (0)