connect.c: mark more strings for translation
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Nguyễn Thái Ngọc Duy committed
Jul 21, 2018 at 09:49 UTC
aad6fddb0cff51ac8adb1e31cd35b06c5fcccc9c
2 files changed
+42
-38
connect.c
+39
-35
@@ -78,7 +78,7 @@ int server_supports_v2(const char *c, int die_on_error)
78
}
79
80
if (die_on_error)
81
- die("server doesn't support '%s'", c);
81
+ die(_("server doesn't support '%s'"), c);
82
83
return 0;
84
}
@@ -100,7 +100,7 @@ int server_supports_feature(const char *c, const char *feature,
100
}
101
102
if (die_on_error)
103
- die("server doesn't support feature '%s'", feature);
103
+ die(_("server doesn't support feature '%s'"), feature);
104
105
return 0;
106
}
@@ -111,7 +111,7 @@ static void process_capabilities_v2(struct packet_reader *reader)
111
argv_array_push(&server_capabilities_v2, reader->line);
112
113
if (reader->status != PACKET_READ_FLUSH)
114
- die("expected flush after capabilities");
114
+ die(_("expected flush after capabilities"));
115
}
116
117
enum protocol_version discover_version(struct packet_reader *reader)
@@ -230,7 +230,7 @@ static int process_dummy_ref(const char *line)
230
static void check_no_capabilities(const char *line, int len)
231
{
232
if (strlen(line) != len)
233
- warning("ignoring capabilities after first line '%s'",
233
+ warning(_("ignoring capabilities after first line '%s'"),
234
line + strlen(line));
235
}
236
@@ -249,7 +249,7 @@ static int process_ref(const char *line, int len, struct ref ***list,
249
if (extra_have && !strcmp(name, ".have")) {
250
oid_array_append(extra_have, &old_oid);
251
} else if (!strcmp(name, "capabilities^{}")) {
252
- die("protocol error: unexpected capabilities^{}");
252
+ die(_("protocol error: unexpected capabilities^{}"));
253
} else if (check_ref(name, flags)) {
254
struct ref *ref = alloc_ref(name);
255
oidcpy(&ref->old_oid, &old_oid);
@@ -270,9 +270,9 @@ static int process_shallow(const char *line, int len,
270
return 0;
271
272
if (get_oid_hex(arg, &old_oid))
273
- die("protocol error: expected shallow sha-1, got '%s'", arg);
273
+ die(_("protocol error: expected shallow sha-1, got '%s'"), arg);
274
if (!shallow_points)
275
- die("repository on the other end cannot be shallow");
275
+ die(_("repository on the other end cannot be shallow"));
276
oid_array_append(shallow_points, &old_oid);
277
check_no_capabilities(line, len);
278
return 1;
@@ -307,13 +307,13 @@ struct ref **get_remote_heads(struct packet_reader *reader,
307
case PACKET_READ_NORMAL:
308
len = reader->pktlen;
309
if (len > 4 && skip_prefix(reader->line, "ERR ", &arg))
310
- die("remote error: %s", arg);
310
+ die(_("remote error: %s"), arg);
311
break;
312
case PACKET_READ_FLUSH:
313
state = EXPECTING_DONE;
314
break;
315
case PACKET_READ_DELIM:
316
- die("invalid packet");
316
+ die(_("invalid packet"));
317
}
318
319
switch (state) {
@@ -333,7 +333,7 @@ struct ref **get_remote_heads(struct packet_reader *reader,
333
case EXPECTING_SHALLOW:
334
if (process_shallow(reader->line, len, shallow_points))
335
break;
336
- die("protocol error: unexpected '%s'", reader->line);
336
+ die(_("protocol error: unexpected '%s'"), reader->line);
337
case EXPECTING_DONE:
338
break;
339
}
@@ -441,11 +441,11 @@ struct ref **get_remote_refs(int fd_out, struct packet_reader *reader,
441
/* Process response from server */
442
while (packet_reader_read(reader) == PACKET_READ_NORMAL) {
443
if (!process_ref_v2(reader->line, &list))
444
- die("invalid ls-refs response: %s", reader->line);
444
+ die(_("invalid ls-refs response: %s"), reader->line);
445
}
446
447
if (reader->status != PACKET_READ_FLUSH)
448
- die("expected flush after ref listing");
448
+ die(_("expected flush after ref listing"));
449
450
return list;
451
}
@@ -544,7 +544,7 @@ static enum protocol get_protocol(const char *name)
544
return PROTO_SSH;
545
if (!strcmp(name, "file"))
546
return PROTO_FILE;
547
- die("protocol '%s' is not supported", name);
547
+ die(_("protocol '%s' is not supported"), name);
548
}
549
550
static char *host_end(char **hoststart, int removebrackets)
@@ -595,7 +595,7 @@ static void enable_keepalive(int sockfd)
595
int ka = 1;
596
597
if (setsockopt(sockfd, SOL_SOCKET, SO_KEEPALIVE, &ka, sizeof(ka)) < 0)
598
- error_errno("unable to set SO_KEEPALIVE on socket");
598
+ error_errno(_("unable to set SO_KEEPALIVE on socket"));
599
}
600
601
#ifndef NO_IPV6
@@ -635,14 +635,15 @@ static int git_tcp_connect_sock(char *host, int flags)
635
hints.ai_protocol = IPPROTO_TCP;
636
637
if (flags & CONNECT_VERBOSE)
638
- fprintf(stderr, "Looking up %s ... ", host);
638
+ fprintf(stderr, _("Looking up %s ... "), host);
639
640
gai = getaddrinfo(host, port, &hints, &ai);
641
if (gai)
642
- die("unable to look up %s (port %s) (%s)", host, port, gai_strerror(gai));
642
+ die(_("unable to look up %s (port %s) (%s)"), host, port, gai_strerror(gai));
643
644
if (flags & CONNECT_VERBOSE)
645
- fprintf(stderr, "done.\nConnecting to %s (port %s) ... ", host, port);
645
+ /* TRANSLATORS: this is the end of "Looking up %s ... " */
646
+ fprintf(stderr, _("done.\nConnecting to %s (port %s) ... "), host, port);
647
648
for (ai0 = ai; ai; ai = ai->ai_next, cnt++) {
649
sockfd = socket(ai->ai_family,
@@ -664,12 +665,13 @@ static int git_tcp_connect_sock(char *host, int flags)
665
freeaddrinfo(ai0);
666
667
if (sockfd < 0)
667
- die("unable to connect to %s:\n%s", host, error_message.buf);
668
+ die(_("unable to connect to %s:\n%s"), host, error_message.buf);
669
670
enable_keepalive(sockfd);
671
672
if (flags & CONNECT_VERBOSE)
672
- fprintf_ln(stderr, "done.");
673
+ /* TRANSLATORS: this is the end of "Connecting to %s (port %s) ... " */
674
+ fprintf_ln(stderr, _("done."));
675
676
strbuf_release(&error_message);
677
@@ -696,22 +698,23 @@ static int git_tcp_connect_sock(char *host, int flags)
698
get_host_and_port(&host, &port);
699
700
if (flags & CONNECT_VERBOSE)
699
- fprintf(stderr, "Looking up %s ... ", host);
701
+ fprintf(stderr, _("Looking up %s ... "), host);
702
703
he = gethostbyname(host);
704
if (!he)
703
- die("unable to look up %s (%s)", host, hstrerror(h_errno));
705
+ die(_("unable to look up %s (%s)"), host, hstrerror(h_errno));
706
nport = strtoul(port, &ep, 10);
707
if ( ep == port || *ep ) {
708
/* Not numeric */
709
struct servent *se = getservbyname(port,"tcp");
710
if ( !se )
709
- die("unknown port %s", port);
711
+ die(_("unknown port %s"), port);
712
nport = se->s_port;
713
}
714
715
if (flags & CONNECT_VERBOSE)
714
- fprintf(stderr, "done.\nConnecting to %s (port %s) ... ", host, port);
716
+ /* TRANSLATORS: this is the end of "Looking up %s ... " */
717
+ fprintf(stderr, _("done.\nConnecting to %s (port %s) ... "), host, port);
718
719
for (cnt = 0, ap = he->h_addr_list; *ap; ap++, cnt++) {
720
memset(&sa, 0, sizeof sa);
@@ -739,12 +742,13 @@ static int git_tcp_connect_sock(char *host, int flags)
742
}
743
744
if (sockfd < 0)
742
- die("unable to connect to %s:\n%s", host, error_message.buf);
745
+ die(_("unable to connect to %s:\n%s"), host, error_message.buf);
746
747
enable_keepalive(sockfd);
748
749
if (flags & CONNECT_VERBOSE)
747
- fprintf_ln(stderr, "done.");
750
+ /* TRANSLATORS: this is the end of "Connecting to %s (port %s) ... " */
751
+ fprintf_ln(stderr, _("done."));
752
753
return sockfd;
754
}
@@ -841,9 +845,9 @@ static struct child_process *git_proxy_connect(int fd[2], char *host)
845
get_host_and_port(&host, &port);
846
847
if (looks_like_command_line_option(host))
844
- die("strange hostname '%s' blocked", host);
848
+ die(_("strange hostname '%s' blocked"), host);
849
if (looks_like_command_line_option(port))
846
- die("strange port '%s' blocked", port);
850
+ die(_("strange port '%s' blocked"), port);
851
852
proxy = xmalloc(sizeof(*proxy));
853
child_process_init(proxy);
@@ -853,7 +857,7 @@ static struct child_process *git_proxy_connect(int fd[2], char *host)
857
proxy->in = -1;
858
proxy->out = -1;
859
if (start_command(proxy))
856
- die("cannot start proxy %s", git_proxy_command);
860
+ die(_("cannot start proxy %s"), git_proxy_command);
861
fd[0] = proxy->out; /* read from proxy stdout */
862
fd[1] = proxy->in; /* write to proxy stdin */
863
return proxy;
@@ -920,7 +924,7 @@ static enum protocol parse_connect_url(const char *url_orig, char **ret_host,
924
path = strchr(end, separator);
925
926
if (!path || !*path)
923
- die("no path specified; see 'git help pull' for valid url syntax");
927
+ die(_("no path specified; see 'git help pull' for valid url syntax"));
928
929
/*
930
* null-terminate hostname and point path to ~ for URL's like this:
@@ -1115,7 +1119,7 @@ static void push_ssh_options(struct argv_array *args, struct argv_array *env,
1119
case VARIANT_AUTO:
1120
BUG("VARIANT_AUTO passed to push_ssh_options");
1121
case VARIANT_SIMPLE:
1118
- die("ssh variant 'simple' does not support -4");
1122
+ die(_("ssh variant 'simple' does not support -4"));
1123
case VARIANT_SSH:
1124
case VARIANT_PLINK:
1125
case VARIANT_PUTTY:
@@ -1127,7 +1131,7 @@ static void push_ssh_options(struct argv_array *args, struct argv_array *env,
1131
case VARIANT_AUTO:
1132
BUG("VARIANT_AUTO passed to push_ssh_options");
1133
case VARIANT_SIMPLE:
1130
- die("ssh variant 'simple' does not support -6");
1134
+ die(_("ssh variant 'simple' does not support -6"));
1135
case VARIANT_SSH:
1136
case VARIANT_PLINK:
1137
case VARIANT_PUTTY:
@@ -1144,7 +1148,7 @@ static void push_ssh_options(struct argv_array *args, struct argv_array *env,
1148
case VARIANT_AUTO:
1149
BUG("VARIANT_AUTO passed to push_ssh_options");
1150
case VARIANT_SIMPLE:
1147
- die("ssh variant 'simple' does not support setting port");
1151
+ die(_("ssh variant 'simple' does not support setting port"));
1152
case VARIANT_SSH:
1153
argv_array_push(args, "-p");
1154
break;
@@ -1167,7 +1171,7 @@ static void fill_ssh_args(struct child_process *conn, const char *ssh_host,
1171
enum ssh_variant variant;
1172
1173
if (looks_like_command_line_option(ssh_host))
1170
- die("strange hostname '%s' blocked", ssh_host);
1174
+ die(_("strange hostname '%s' blocked"), ssh_host);
1175
1176
ssh = get_ssh_command();
1177
if (ssh) {
@@ -1255,7 +1259,7 @@ struct child_process *git_connect(int fd[2], const char *url,
1259
child_process_init(conn);
1260
1261
if (looks_like_command_line_option(path))
1258
- die("strange pathname '%s' blocked", path);
1262
+ die(_("strange pathname '%s' blocked"), path);
1263
1264
strbuf_addstr(&cmd, prog);
1265
strbuf_addch(&cmd, ' ');
@@ -1300,7 +1304,7 @@ struct child_process *git_connect(int fd[2], const char *url,
1304
argv_array_push(&conn->args, cmd.buf);
1305
1306
if (start_command(conn))
1303
- die("unable to fork");
1307
+ die(_("unable to fork"));
1308
1309
fd[0] = conn->out; /* read from child's stdout */
1310
fd[1] = conn->in; /* write to child's stdin */
t/t5570-git-daemon.sh
+3
-3
@@ -7,9 +7,9 @@ test_description='test fetching over git protocol'
7
start_git_daemon
8
9
check_verbose_connect () {
10
- grep -F "Looking up 127.0.0.1 ..." stderr &&
11
- grep -F "Connecting to 127.0.0.1 (port " stderr &&
12
- grep -F "done." stderr
10
+ test_i18ngrep -F "Looking up 127.0.0.1 ..." stderr &&
11
+ test_i18ngrep -F "Connecting to 127.0.0.1 (port " stderr &&
12
+ test_i18ngrep -F "done." stderr
13
}
14
15
test_expect_success 'setup repository' '