|
26 | 26 | #include "transport.h" |
27 | 27 | #include "url.h" |
28 | 28 | #include "write-or-die.h" |
| 29 | +#include "utf8.h" |
29 | 30 |
|
30 | 31 | static struct remote *remote; |
31 | 32 | /* always ends with a trailing slash */ |
@@ -540,10 +541,38 @@ static struct discovery *discover_refs(const char *service, int for_push) |
540 | 541 | show_http_message_fatal(&type, &charset, &buffer, |
541 | 542 | _("unable to access '%s' with http.pinnedPubkey configuration: %s"), |
542 | 543 | transport_anonymize_url(url.buf), curl_errorstr); |
543 | | - case HTTP_RATE_LIMITED: |
544 | | - show_http_message_fatal(&type, &charset, &buffer, |
545 | | - _("rate limited by '%s', please try again later"), |
546 | | - transport_anonymize_url(url.buf)); |
| 544 | + case HTTP_RATE_LIMITED: { |
| 545 | + const char *p, *eol; |
| 546 | + struct strbuf msgbuf = STRBUF_INIT; |
| 547 | + char *anonymized_url = transport_anonymize_url(url.buf); |
| 548 | + |
| 549 | + /* |
| 550 | + * We only show text/plain parts, as other types are likely |
| 551 | + * to be ugly to look at on the user's terminal. |
| 552 | + */ |
| 553 | + if (!strcmp(type.buf, "text/plain")) { |
| 554 | + strbuf_addbuf(&msgbuf, &buffer); |
| 555 | + if (charset.len) |
| 556 | + strbuf_reencode(&msgbuf, charset.buf, get_log_output_encoding()); |
| 557 | + |
| 558 | + strbuf_trim(&msgbuf); |
| 559 | + if (msgbuf.len) { |
| 560 | + p = msgbuf.buf; |
| 561 | + do { |
| 562 | + eol = strchrnul(p, '\n'); |
| 563 | + fprintf(stderr, "remote: %.*s\n", (int)(eol - p), p); |
| 564 | + p = eol + 1; |
| 565 | + } while(*eol); |
| 566 | + } |
| 567 | + strbuf_release(&msgbuf); |
| 568 | + } |
| 569 | + |
| 570 | + strbuf_release(&type); |
| 571 | + strbuf_release(&charset); |
| 572 | + strbuf_release(&buffer); |
| 573 | + |
| 574 | + die(_("rate limited by '%s', please try again later"), anonymized_url); |
| 575 | + } |
547 | 576 | default: |
548 | 577 | show_http_message_fatal(&type, &charset, &buffer, |
549 | 578 | _("unable to access '%s': %s"), |
|
0 commit comments