Yup. The wonky error message is generated in
remote-curl.c:run_slot().
If one does a web search for the error message, almost all of them misunderstand what is going on, even though it is pretty common (compared to other errors when using git). I wonder if sending a request for comments for a patch changing
remote-curl.c:run_slot() into something like
static int run_slot(struct active_request_slot *slot,
struct slot_results *results)
{
int err;
struct slot_results results_buf;
if (!results)
results = &results_buf;
err = run_one_slot(slot, results);
if (err == HTTP_OK || err == HTTP_REAUTH)
return err;
/*
* RPC failed. Generate an understandable error message
* for the case where the connection was unexpectedly closed,
* for example due to TCP RST packet injection.
*/
if (err == HTTP_ERROR && results->http_code == 200 &&
results->curl_result == CURLE_PARTIAL_FILE) {
error(_("Connection closed unexpectedly; TCP RST injection?"));
return err;
}
/*
* Default error reporting for all other errors.
*/
struct strbuf msg = STRBUF_INIT;
if (results->http_code && results->http_code != 200)
strbuf_addf(&msg, "HTTP %ld", results->http_code);
if (results->curl_result != CURLE_OK) {
if (msg.len)
strbuf_addch(&msg, ' ');
strbuf_addf(&msg, "curl %d", results->curl_result);
if (curl_errorstr[0]) {
strbuf_addch(&msg, ' ');
strbuf_addstr(&msg, curl_errorstr);
}
}
error(_("RPC failed; %s"), msg.buf);
strbuf_release(&msg);
return err;
}
would be useful for users, possibly adding more dedicated cases for specific other
curl errors, specifically
CURLE_RECV_ERROR (indicating a problem in the local network stack), and explaining how no local or configuration changes can help with this particular error (contrary to many, many reports one can find via web searches), because it is either generated by the server, or by a router in between. It cannot happen due to just a sudden loss of connection, temporary or permanent, because it can only be due to receiving an explicit end-of-connection packet, TCP RST, which intermediate devices are supposed to not generate, but many ISPs use in an effort to combat file sharing, legal or otherwise. (Hardware connection loss at any point will show up as a timeout-related error instead, with the transfer "hanging", which is easy to detect by a human.)
Typical HTTP errors are already handled separately in
http.c:handle_curl_result() called by
http.c:run_one_slot() (causing the above
remote-curl.c:run_slot() see
err = HTTP_ERROR, and printing the additional error message). Putting simplified error reports into
remote-curl.c:run_slot() means only the simplified error message is shown, adding the likelihood that human users understand the cause of the error right, and don't get confused by the additional error information (which is useless in this particular error condition, due to the very limited set of error causes).
I'm personally not mentally prepared to deal with the social stuff in pushing changes to other peoples' code right now, especially because bringing up the habit of some ISPs using TCP RST injection to "combat file sharing" will cause a nasty chain at the
git@vger.kernel.org mailing list, where one should be subscribed before submitting patches for comments or consideration. As you can see from my suggested ISP "support ticket" above, I'd just pour fuel to the flames, because this annoys me so much (having gone through this myself a decade ago, downloading Linux distro DVD images). Hell, I can't even do my favourite hobbies, like drive-by bug fix submissions to open source projects right now, for the same reason.
