Skip to content

Commit aad6fdd

Browse files
pcloudsgitster
authored andcommitted
connect.c: mark more strings for translation
Signed-off-by: Nguyễn Thái Ngọc Duy <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent a769bfc commit aad6fdd

File tree

2 files changed

+42
-38
lines changed

2 files changed

+42
-38
lines changed

connect.c

Lines changed: 39 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ int server_supports_v2(const char *c, int die_on_error)
7878
}
7979

8080
if (die_on_error)
81-
die("server doesn't support '%s'", c);
81+
die(_("server doesn't support '%s'"), c);
8282

8383
return 0;
8484
}
@@ -100,7 +100,7 @@ int server_supports_feature(const char *c, const char *feature,
100100
}
101101

102102
if (die_on_error)
103-
die("server doesn't support feature '%s'", feature);
103+
die(_("server doesn't support feature '%s'"), feature);
104104

105105
return 0;
106106
}
@@ -111,7 +111,7 @@ static void process_capabilities_v2(struct packet_reader *reader)
111111
argv_array_push(&server_capabilities_v2, reader->line);
112112

113113
if (reader->status != PACKET_READ_FLUSH)
114-
die("expected flush after capabilities");
114+
die(_("expected flush after capabilities"));
115115
}
116116

117117
enum protocol_version discover_version(struct packet_reader *reader)
@@ -230,7 +230,7 @@ static int process_dummy_ref(const char *line)
230230
static void check_no_capabilities(const char *line, int len)
231231
{
232232
if (strlen(line) != len)
233-
warning("ignoring capabilities after first line '%s'",
233+
warning(_("ignoring capabilities after first line '%s'"),
234234
line + strlen(line));
235235
}
236236

@@ -249,7 +249,7 @@ static int process_ref(const char *line, int len, struct ref ***list,
249249
if (extra_have && !strcmp(name, ".have")) {
250250
oid_array_append(extra_have, &old_oid);
251251
} else if (!strcmp(name, "capabilities^{}")) {
252-
die("protocol error: unexpected capabilities^{}");
252+
die(_("protocol error: unexpected capabilities^{}"));
253253
} else if (check_ref(name, flags)) {
254254
struct ref *ref = alloc_ref(name);
255255
oidcpy(&ref->old_oid, &old_oid);
@@ -270,9 +270,9 @@ static int process_shallow(const char *line, int len,
270270
return 0;
271271

272272
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);
274274
if (!shallow_points)
275-
die("repository on the other end cannot be shallow");
275+
die(_("repository on the other end cannot be shallow"));
276276
oid_array_append(shallow_points, &old_oid);
277277
check_no_capabilities(line, len);
278278
return 1;
@@ -307,13 +307,13 @@ struct ref **get_remote_heads(struct packet_reader *reader,
307307
case PACKET_READ_NORMAL:
308308
len = reader->pktlen;
309309
if (len > 4 && skip_prefix(reader->line, "ERR ", &arg))
310-
die("remote error: %s", arg);
310+
die(_("remote error: %s"), arg);
311311
break;
312312
case PACKET_READ_FLUSH:
313313
state = EXPECTING_DONE;
314314
break;
315315
case PACKET_READ_DELIM:
316-
die("invalid packet");
316+
die(_("invalid packet"));
317317
}
318318

319319
switch (state) {
@@ -333,7 +333,7 @@ struct ref **get_remote_heads(struct packet_reader *reader,
333333
case EXPECTING_SHALLOW:
334334
if (process_shallow(reader->line, len, shallow_points))
335335
break;
336-
die("protocol error: unexpected '%s'", reader->line);
336+
die(_("protocol error: unexpected '%s'"), reader->line);
337337
case EXPECTING_DONE:
338338
break;
339339
}
@@ -441,11 +441,11 @@ struct ref **get_remote_refs(int fd_out, struct packet_reader *reader,
441441
/* Process response from server */
442442
while (packet_reader_read(reader) == PACKET_READ_NORMAL) {
443443
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);
445445
}
446446

447447
if (reader->status != PACKET_READ_FLUSH)
448-
die("expected flush after ref listing");
448+
die(_("expected flush after ref listing"));
449449

450450
return list;
451451
}
@@ -544,7 +544,7 @@ static enum protocol get_protocol(const char *name)
544544
return PROTO_SSH;
545545
if (!strcmp(name, "file"))
546546
return PROTO_FILE;
547-
die("protocol '%s' is not supported", name);
547+
die(_("protocol '%s' is not supported"), name);
548548
}
549549

550550
static char *host_end(char **hoststart, int removebrackets)
@@ -595,7 +595,7 @@ static void enable_keepalive(int sockfd)
595595
int ka = 1;
596596

597597
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"));
599599
}
600600

601601
#ifndef NO_IPV6
@@ -635,14 +635,15 @@ static int git_tcp_connect_sock(char *host, int flags)
635635
hints.ai_protocol = IPPROTO_TCP;
636636

637637
if (flags & CONNECT_VERBOSE)
638-
fprintf(stderr, "Looking up %s ... ", host);
638+
fprintf(stderr, _("Looking up %s ... "), host);
639639

640640
gai = getaddrinfo(host, port, &hints, &ai);
641641
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));
643643

644644
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);
646647

647648
for (ai0 = ai; ai; ai = ai->ai_next, cnt++) {
648649
sockfd = socket(ai->ai_family,
@@ -664,12 +665,13 @@ static int git_tcp_connect_sock(char *host, int flags)
664665
freeaddrinfo(ai0);
665666

666667
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);
668669

669670
enable_keepalive(sockfd);
670671

671672
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."));
673675

674676
strbuf_release(&error_message);
675677

@@ -696,22 +698,23 @@ static int git_tcp_connect_sock(char *host, int flags)
696698
get_host_and_port(&host, &port);
697699

698700
if (flags & CONNECT_VERBOSE)
699-
fprintf(stderr, "Looking up %s ... ", host);
701+
fprintf(stderr, _("Looking up %s ... "), host);
700702

701703
he = gethostbyname(host);
702704
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));
704706
nport = strtoul(port, &ep, 10);
705707
if ( ep == port || *ep ) {
706708
/* Not numeric */
707709
struct servent *se = getservbyname(port,"tcp");
708710
if ( !se )
709-
die("unknown port %s", port);
711+
die(_("unknown port %s"), port);
710712
nport = se->s_port;
711713
}
712714

713715
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);
715718

716719
for (cnt = 0, ap = he->h_addr_list; *ap; ap++, cnt++) {
717720
memset(&sa, 0, sizeof sa);
@@ -739,12 +742,13 @@ static int git_tcp_connect_sock(char *host, int flags)
739742
}
740743

741744
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);
743746

744747
enable_keepalive(sockfd);
745748

746749
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."));
748752

749753
return sockfd;
750754
}
@@ -841,9 +845,9 @@ static struct child_process *git_proxy_connect(int fd[2], char *host)
841845
get_host_and_port(&host, &port);
842846

843847
if (looks_like_command_line_option(host))
844-
die("strange hostname '%s' blocked", host);
848+
die(_("strange hostname '%s' blocked"), host);
845849
if (looks_like_command_line_option(port))
846-
die("strange port '%s' blocked", port);
850+
die(_("strange port '%s' blocked"), port);
847851

848852
proxy = xmalloc(sizeof(*proxy));
849853
child_process_init(proxy);
@@ -853,7 +857,7 @@ static struct child_process *git_proxy_connect(int fd[2], char *host)
853857
proxy->in = -1;
854858
proxy->out = -1;
855859
if (start_command(proxy))
856-
die("cannot start proxy %s", git_proxy_command);
860+
die(_("cannot start proxy %s"), git_proxy_command);
857861
fd[0] = proxy->out; /* read from proxy stdout */
858862
fd[1] = proxy->in; /* write to proxy stdin */
859863
return proxy;
@@ -920,7 +924,7 @@ static enum protocol parse_connect_url(const char *url_orig, char **ret_host,
920924
path = strchr(end, separator);
921925

922926
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"));
924928

925929
/*
926930
* 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,
11151119
case VARIANT_AUTO:
11161120
BUG("VARIANT_AUTO passed to push_ssh_options");
11171121
case VARIANT_SIMPLE:
1118-
die("ssh variant 'simple' does not support -4");
1122+
die(_("ssh variant 'simple' does not support -4"));
11191123
case VARIANT_SSH:
11201124
case VARIANT_PLINK:
11211125
case VARIANT_PUTTY:
@@ -1127,7 +1131,7 @@ static void push_ssh_options(struct argv_array *args, struct argv_array *env,
11271131
case VARIANT_AUTO:
11281132
BUG("VARIANT_AUTO passed to push_ssh_options");
11291133
case VARIANT_SIMPLE:
1130-
die("ssh variant 'simple' does not support -6");
1134+
die(_("ssh variant 'simple' does not support -6"));
11311135
case VARIANT_SSH:
11321136
case VARIANT_PLINK:
11331137
case VARIANT_PUTTY:
@@ -1144,7 +1148,7 @@ static void push_ssh_options(struct argv_array *args, struct argv_array *env,
11441148
case VARIANT_AUTO:
11451149
BUG("VARIANT_AUTO passed to push_ssh_options");
11461150
case VARIANT_SIMPLE:
1147-
die("ssh variant 'simple' does not support setting port");
1151+
die(_("ssh variant 'simple' does not support setting port"));
11481152
case VARIANT_SSH:
11491153
argv_array_push(args, "-p");
11501154
break;
@@ -1167,7 +1171,7 @@ static void fill_ssh_args(struct child_process *conn, const char *ssh_host,
11671171
enum ssh_variant variant;
11681172

11691173
if (looks_like_command_line_option(ssh_host))
1170-
die("strange hostname '%s' blocked", ssh_host);
1174+
die(_("strange hostname '%s' blocked"), ssh_host);
11711175

11721176
ssh = get_ssh_command();
11731177
if (ssh) {
@@ -1255,7 +1259,7 @@ struct child_process *git_connect(int fd[2], const char *url,
12551259
child_process_init(conn);
12561260

12571261
if (looks_like_command_line_option(path))
1258-
die("strange pathname '%s' blocked", path);
1262+
die(_("strange pathname '%s' blocked"), path);
12591263

12601264
strbuf_addstr(&cmd, prog);
12611265
strbuf_addch(&cmd, ' ');
@@ -1300,7 +1304,7 @@ struct child_process *git_connect(int fd[2], const char *url,
13001304
argv_array_push(&conn->args, cmd.buf);
13011305

13021306
if (start_command(conn))
1303-
die("unable to fork");
1307+
die(_("unable to fork"));
13041308

13051309
fd[0] = conn->out; /* read from child's stdout */
13061310
fd[1] = conn->in; /* write to child's stdin */

t/t5570-git-daemon.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ test_description='test fetching over git protocol'
77
start_git_daemon
88

99
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
1313
}
1414

1515
test_expect_success 'setup repository' '

0 commit comments

Comments
 (0)