Skip to content

Commit

Permalink
Merge branch 'js/remote-curl-i18n'
Browse files Browse the repository at this point in the history
Error messages given from the http transport have been updated so
that they can be localized.

* js/remote-curl-i18n:
  remote-curl: mark all error messages for translation
  • Loading branch information
gitster committed Apr 16, 2019
2 parents 764bd20 + ed8b413 commit aa1edf1
Showing 1 changed file with 25 additions and 25 deletions.
50 changes: 25 additions & 25 deletions remote-curl.c
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ static int set_option(const char *name, const char *value)
else {
struct strbuf unquoted = STRBUF_INIT;
if (unquote_c_style(&unquoted, value, NULL) < 0)
die("invalid quoting in push-option value");
die(_("invalid quoting in push-option value: '%s'"), value);
string_list_append_nodup(&options.push_options,
strbuf_detach(&unquoted, NULL));
}
Expand Down Expand Up @@ -251,7 +251,7 @@ static struct ref *parse_info_refs(struct discovery *heads)
mid = &data[i];
if (data[i] == '\n') {
if (mid - start != 40)
die("%sinfo/refs not valid: is this a git repository?",
die(_("%sinfo/refs not valid: is this a git repository?"),
transport_anonymize_url(url.buf));
data[i] = 0;
ref_name = mid + 1;
Expand Down Expand Up @@ -352,7 +352,7 @@ static void check_smart_http(struct discovery *d, const char *service,
PACKET_READ_CHOMP_NEWLINE |
PACKET_READ_DIE_ON_ERR_PACKET);
if (packet_reader_read(&reader) != PACKET_READ_NORMAL)
die("invalid server response; expected service, got flush packet");
die(_("invalid server response; expected service, got flush packet"));

if (skip_prefix(reader.line, "# service=", &p) && !strcmp(p, service)) {
/*
Expand Down Expand Up @@ -383,7 +383,7 @@ static void check_smart_http(struct discovery *d, const char *service,
d->proto_git = 1;

} else {
die("invalid server response; got '%s'", reader.line);
die(_("invalid server response; got '%s'"), reader.line);
}
}

Expand Down Expand Up @@ -443,15 +443,15 @@ static struct discovery *discover_refs(const char *service, int for_push)
break;
case HTTP_MISSING_TARGET:
show_http_message(&type, &charset, &buffer);
die("repository '%s' not found",
die(_("repository '%s' not found"),
transport_anonymize_url(url.buf));
case HTTP_NOAUTH:
show_http_message(&type, &charset, &buffer);
die("Authentication failed for '%s'",
die(_("Authentication failed for '%s'"),
transport_anonymize_url(url.buf));
default:
show_http_message(&type, &charset, &buffer);
die("unable to access '%s': %s",
die(_("unable to access '%s': %s"),
transport_anonymize_url(url.buf), curl_errorstr);
}

Expand Down Expand Up @@ -581,7 +581,7 @@ static int rpc_read_from_out(struct rpc_state *rpc, int options,
switch (*status) {
case PACKET_READ_EOF:
if (!(options & PACKET_READ_GENTLE_ON_EOF))
die("shouldn't have EOF when not gentle on EOF");
die(_("shouldn't have EOF when not gentle on EOF"));
break;
case PACKET_READ_NORMAL:
set_packet_header(buf - 4, *appended);
Expand Down Expand Up @@ -661,7 +661,7 @@ static curlioerr rpc_ioctl(CURL *handle, int cmd, void *clientp)
rpc->pos = 0;
return CURLIOE_OK;
}
error("unable to rewind rpc post data - try increasing http.postBuffer");
error(_("unable to rewind rpc post data - try increasing http.postBuffer"));
return CURLIOE_FAILRESTART;

default:
Expand Down Expand Up @@ -721,7 +721,7 @@ static int run_slot(struct active_request_slot *slot,
strbuf_addstr(&msg, curl_errorstr);
}
}
error("RPC failed; %s", msg.buf);
error(_("RPC failed; %s"), msg.buf);
strbuf_release(&msg);
}

Expand Down Expand Up @@ -761,7 +761,7 @@ static curl_off_t xcurl_off_t(size_t len)
{
uintmax_t size = len;
if (size > maximum_signed_value_of_type(curl_off_t))
die("cannot handle pushes this big");
die(_("cannot handle pushes this big"));
return (curl_off_t)size;
}

Expand Down Expand Up @@ -876,11 +876,11 @@ static int post_rpc(struct rpc_state *rpc, int flush_received)

ret = git_deflate(&stream, Z_FINISH);
if (ret != Z_STREAM_END)
die("cannot deflate request; zlib deflate error %d", ret);
die(_("cannot deflate request; zlib deflate error %d"), ret);

ret = git_deflate_end_gently(&stream);
if (ret != Z_OK)
die("cannot deflate request; zlib end error %d", ret);
die(_("cannot deflate request; zlib end error %d"), ret);

gzip_size = stream.total_out;

Expand Down Expand Up @@ -1011,7 +1011,7 @@ static int fetch_dumb(int nr_heads, struct ref **to_fetch)

ALLOC_ARRAY(targets, nr_heads);
if (options.depth || options.deepen_since)
die("dumb http transport does not support shallow capabilities");
die(_("dumb http transport does not support shallow capabilities"));
for (i = 0; i < nr_heads; i++)
targets[i] = xstrdup(oid_to_hex(&to_fetch[i]->old_oid));

Expand All @@ -1025,7 +1025,7 @@ static int fetch_dumb(int nr_heads, struct ref **to_fetch)
free(targets[i]);
free(targets);

return ret ? error("fetch failed.") : 0;
return ret ? error(_("fetch failed.")) : 0;
}

static int fetch_git(struct discovery *heads,
Expand Down Expand Up @@ -1073,7 +1073,7 @@ static int fetch_git(struct discovery *heads,
for (i = 0; i < nr_heads; i++) {
struct ref *ref = to_fetch[i];
if (!*ref->name)
die("cannot fetch by sha1 over smart http");
die(_("cannot fetch by sha1 over smart http"));
packet_buf_write(&preamble, "%s %s\n",
oid_to_hex(&ref->old_oid), ref->name);
}
Expand Down Expand Up @@ -1116,13 +1116,13 @@ static void parse_fetch(struct strbuf *buf)
struct object_id old_oid;

if (get_oid_hex(p, &old_oid))
die("protocol error: expected sha/ref, got %s'", p);
die(_("protocol error: expected sha/ref, got %s'"), p);
if (p[GIT_SHA1_HEXSZ] == ' ')
name = p + GIT_SHA1_HEXSZ + 1;
else if (!p[GIT_SHA1_HEXSZ])
name = "";
else
die("protocol error: expected sha/ref, got %s'", p);
die(_("protocol error: expected sha/ref, got %s'"), p);

ref = alloc_ref(name);
oidcpy(&ref->old_oid, &old_oid);
Expand All @@ -1134,7 +1134,7 @@ static void parse_fetch(struct strbuf *buf)
to_fetch[nr_heads++] = ref;
}
else
die("http transport does not support %s", buf->buf);
die(_("http transport does not support %s"), buf->buf);

strbuf_reset(buf);
if (strbuf_getline_lf(buf, stdin) == EOF)
Expand Down Expand Up @@ -1170,7 +1170,7 @@ static int push_dav(int nr_spec, char **specs)
argv_array_push(&child.args, specs[i]);

if (run_command(&child))
die("git-http-push failed");
die(_("git-http-push failed"));
return 0;
}

Expand Down Expand Up @@ -1248,7 +1248,7 @@ static void parse_push(struct strbuf *buf)
specs[nr_spec++] = xstrdup(buf->buf + 5);
}
else
die("http transport does not support %s", buf->buf);
die(_("http transport does not support %s"), buf->buf);

strbuf_reset(buf);
if (strbuf_getline_lf(buf, stdin) == EOF)
Expand Down Expand Up @@ -1356,7 +1356,7 @@ int cmd_main(int argc, const char **argv)

setup_git_directory_gently(&nongit);
if (argc < 2) {
error("remote-curl: usage: git remote-curl <remote> [<url>]");
error(_("remote-curl: usage: git remote-curl <remote> [<url>]"));
return 1;
}

Expand Down Expand Up @@ -1388,14 +1388,14 @@ int cmd_main(int argc, const char **argv)

if (strbuf_getline_lf(&buf, stdin) == EOF) {
if (ferror(stdin))
error("remote-curl: error reading command stream from git");
error(_("remote-curl: error reading command stream from git"));
return 1;
}
if (buf.len == 0)
break;
if (starts_with(buf.buf, "fetch ")) {
if (nongit)
die("remote-curl: fetch attempted without a local repo");
die(_("remote-curl: fetch attempted without a local repo"));
parse_fetch(&buf);

} else if (!strcmp(buf.buf, "list") || starts_with(buf.buf, "list ")) {
Expand Down Expand Up @@ -1435,7 +1435,7 @@ int cmd_main(int argc, const char **argv)
if (!stateless_connect(arg))
break;
} else {
error("remote-curl: unknown command '%s' from git", buf.buf);
error(_("remote-curl: unknown command '%s' from git"), buf.buf);
return 1;
}
strbuf_reset(&buf);
Expand Down

0 comments on commit aa1edf1

Please sign in to comment.