Skip to content

Commit 6b5b309

Browse files
pcloudsgitster
authored andcommitted
transport-helper.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 68e39e4 commit 6b5b309

File tree

2 files changed

+48
-47
lines changed

2 files changed

+48
-47
lines changed

t/t5801-remote-helpers.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -126,15 +126,15 @@ test_expect_success 'forced push' '
126126
test_expect_success 'cloning without refspec' '
127127
GIT_REMOTE_TESTGIT_REFSPEC="" \
128128
git clone "testgit::${PWD}/server" local2 2>error &&
129-
grep "this remote helper should implement refspec capability" error &&
129+
test_i18ngrep "this remote helper should implement refspec capability" error &&
130130
compare_refs local2 HEAD server HEAD
131131
'
132132

133133
test_expect_success 'pulling without refspecs' '
134134
(cd local2 &&
135135
git reset --hard &&
136136
GIT_REMOTE_TESTGIT_REFSPEC="" git pull 2>../error) &&
137-
grep "this remote helper should implement refspec capability" error &&
137+
test_i18ngrep "this remote helper should implement refspec capability" error &&
138138
compare_refs local2 HEAD server HEAD
139139
'
140140

@@ -146,7 +146,7 @@ test_expect_success 'pushing without refspecs' '
146146
GIT_REMOTE_TESTGIT_REFSPEC="" &&
147147
export GIT_REMOTE_TESTGIT_REFSPEC &&
148148
test_must_fail git push 2>../error) &&
149-
grep "remote-helper doesn.t support push; refspec needed" error
149+
test_i18ngrep "remote-helper doesn.t support push; refspec needed" error
150150
'
151151

152152
test_expect_success 'pulling without marks' '
@@ -246,7 +246,7 @@ test_expect_success 'proper failure checks for fetching' '
246246
(cd local &&
247247
test_must_fail env GIT_REMOTE_TESTGIT_FAILURE=1 git fetch 2>error &&
248248
cat error &&
249-
grep -q "error while running fast-import" error
249+
test_i18ngrep -q "error while running fast-import" error
250250
)
251251
'
252252

transport-helper.c

Lines changed: 44 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ static void sendline(struct helper_data *helper, struct strbuf *buffer)
4848
if (debug)
4949
fprintf(stderr, "Debug: Remote helper: -> %s", buffer->buf);
5050
if (write_in_full(helper->helper->in, buffer->buf, buffer->len) < 0)
51-
die_errno("full write to remote helper failed");
51+
die_errno(_("full write to remote helper failed"));
5252
}
5353

5454
static int recvline_fh(FILE *helper, struct strbuf *buffer)
@@ -77,7 +77,7 @@ static void write_constant(int fd, const char *str)
7777
if (debug)
7878
fprintf(stderr, "Debug: Remote helper: -> %s", str);
7979
if (write_in_full(fd, str, strlen(str)) < 0)
80-
die_errno("full write to remote helper failed");
80+
die_errno(_("full write to remote helper failed"));
8181
}
8282

8383
static const char *remove_ext_force(const char *url)
@@ -129,7 +129,7 @@ static struct child_process *get_helper(struct transport *transport)
129129

130130
code = start_command(helper);
131131
if (code < 0 && errno == ENOENT)
132-
die("unable to find remote helper for '%s'", data->name);
132+
die(_("unable to find remote helper for '%s'"), data->name);
133133
else if (code != 0)
134134
exit(code);
135135

@@ -145,7 +145,7 @@ static struct child_process *get_helper(struct transport *transport)
145145
*/
146146
duped = dup(helper->out);
147147
if (duped < 0)
148-
die_errno("can't dup helper output fd");
148+
die_errno(_("can't dup helper output fd"));
149149
data->out = xfdopen(duped, "r");
150150

151151
write_constant(helper->in, "capabilities\n");
@@ -196,13 +196,13 @@ static struct child_process *get_helper(struct transport *transport)
196196
} else if (starts_with(capname, "no-private-update")) {
197197
data->no_private_update = 1;
198198
} else if (mandatory) {
199-
die("unknown mandatory capability %s; this remote "
200-
"helper probably needs newer version of Git",
199+
die(_("unknown mandatory capability %s; this remote "
200+
"helper probably needs newer version of Git"),
201201
capname);
202202
}
203203
}
204204
if (!data->rs.nr && (data->import || data->bidi_import || data->export)) {
205-
warning("this remote helper should implement refspec capability");
205+
warning(_("this remote helper should implement refspec capability"));
206206
}
207207
strbuf_release(&buf);
208208
if (debug)
@@ -269,7 +269,7 @@ static int strbuf_set_helper_option(struct helper_data *data,
269269
else if (!strcmp(buf->buf, "unsupported"))
270270
ret = 1;
271271
else {
272-
warning("%s unexpectedly said: '%s'", data->name, buf->buf);
272+
warning(_("%s unexpectedly said: '%s'"), data->name, buf->buf);
273273
ret = 1;
274274
}
275275
return ret;
@@ -398,7 +398,7 @@ static int fetch_with_fetch(struct transport *transport,
398398
if (starts_with(buf.buf, "lock ")) {
399399
const char *name = buf.buf + 5;
400400
if (transport->pack_lockfile)
401-
warning("%s also locked %s", data->name, name);
401+
warning(_("%s also locked %s"), data->name, name);
402402
else
403403
transport->pack_lockfile = xstrdup(name);
404404
}
@@ -409,7 +409,7 @@ static int fetch_with_fetch(struct transport *transport,
409409
else if (!buf.len)
410410
break;
411411
else
412-
warning("%s unexpectedly said: '%s'", data->name, buf.buf);
412+
warning(_("%s unexpectedly said: '%s'"), data->name, buf.buf);
413413
}
414414
strbuf_release(&buf);
415415
return 0;
@@ -476,7 +476,7 @@ static int fetch_with_import(struct transport *transport,
476476
get_helper(transport);
477477

478478
if (get_importer(transport, &fastimport))
479-
die("couldn't run fast-import");
479+
die(_("couldn't run fast-import"));
480480

481481
for (i = 0; i < nr_heads; i++) {
482482
posn = to_fetch[i];
@@ -499,7 +499,7 @@ static int fetch_with_import(struct transport *transport,
499499
*/
500500

501501
if (finish_command(&fastimport))
502-
die("error while running fast-import");
502+
die(_("error while running fast-import"));
503503

504504
/*
505505
* The fast-import stream of a remote helper that advertises
@@ -528,7 +528,7 @@ static int fetch_with_import(struct transport *transport,
528528
private = xstrdup(name);
529529
if (private) {
530530
if (read_ref(private, &posn->old_oid) < 0)
531-
die("could not read ref %s", private);
531+
die(_("could not read ref %s"), private);
532532
free(private);
533533
}
534534
}
@@ -554,7 +554,7 @@ static int run_connect(struct transport *transport, struct strbuf *cmdbuf)
554554
*/
555555
duped = dup(helper->out);
556556
if (duped < 0)
557-
die_errno("can't dup helper output fd");
557+
die_errno(_("can't dup helper output fd"));
558558
input = xfdopen(duped, "r");
559559
setvbuf(input, NULL, _IONBF, 0);
560560

@@ -573,8 +573,8 @@ static int run_connect(struct transport *transport, struct strbuf *cmdbuf)
573573
fprintf(stderr, "Debug: Falling back to dumb "
574574
"transport.\n");
575575
} else {
576-
die("unknown response to connect: %s",
577-
cmdbuf->buf);
576+
die(_(_("unknown response to connect: %s")),
577+
cmdbuf->buf);
578578
}
579579

580580
fclose(input);
@@ -595,9 +595,9 @@ static int process_connect_service(struct transport *transport,
595595
if (strcmp(name, exec)) {
596596
int r = set_helper_option(transport, "servpath", exec);
597597
if (r > 0)
598-
warning("setting remote service path not supported by protocol");
598+
warning(_("setting remote service path not supported by protocol"));
599599
else if (r < 0)
600-
warning("invalid remote service path");
600+
warning(_("invalid remote service path"));
601601
}
602602

603603
if (data->connect) {
@@ -640,10 +640,10 @@ static int connect_helper(struct transport *transport, const char *name,
640640
/* Get_helper so connect is inited. */
641641
get_helper(transport);
642642
if (!data->connect)
643-
die("operation not supported by protocol");
643+
die(_("operation not supported by protocol"));
644644

645645
if (!process_connect_service(transport, name, exec))
646-
die("can't connect to subservice %s", name);
646+
die(_("can't connect to subservice %s"), name);
647647

648648
fd[0] = data->helper->out;
649649
fd[1] = data->helper->in;
@@ -707,7 +707,7 @@ static int push_update_ref_status(struct strbuf *buf,
707707
status = REF_STATUS_REMOTE_REJECT;
708708
refname = buf->buf + 6;
709709
} else
710-
die("expected ok/error, helper said '%s'", buf->buf);
710+
die(_("expected ok/error, helper said '%s'"), buf->buf);
711711

712712
msg = strchr(refname, ' ');
713713
if (msg) {
@@ -760,7 +760,7 @@ static int push_update_ref_status(struct strbuf *buf,
760760
if (!*ref)
761761
*ref = find_ref_by_name(remote_refs, refname);
762762
if (!*ref) {
763-
warning("helper reported unexpected status of %s", refname);
763+
warning(_("helper reported unexpected status of %s"), refname);
764764
return 1;
765765
}
766766

@@ -821,20 +821,20 @@ static void set_common_push_options(struct transport *transport,
821821
{
822822
if (flags & TRANSPORT_PUSH_DRY_RUN) {
823823
if (set_helper_option(transport, "dry-run", "true") != 0)
824-
die("helper %s does not support dry-run", name);
824+
die(_("helper %s does not support dry-run"), name);
825825
} else if (flags & TRANSPORT_PUSH_CERT_ALWAYS) {
826826
if (set_helper_option(transport, TRANS_OPT_PUSH_CERT, "true") != 0)
827-
die("helper %s does not support --signed", name);
827+
die(_("helper %s does not support --signed"), name);
828828
} else if (flags & TRANSPORT_PUSH_CERT_IF_ASKED) {
829829
if (set_helper_option(transport, TRANS_OPT_PUSH_CERT, "if-asked") != 0)
830-
die("helper %s does not support --signed=if-asked", name);
830+
die(_("helper %s does not support --signed=if-asked"), name);
831831
}
832832

833833
if (flags & TRANSPORT_PUSH_OPTIONS) {
834834
struct string_list_item *item;
835835
for_each_string_list_item(item, transport->push_options)
836836
if (set_helper_option(transport, "push-option", item->string) != 0)
837-
die("helper %s does not support 'push-option'", name);
837+
die(_("helper %s does not support 'push-option'"), name);
838838
}
839839
}
840840

@@ -926,12 +926,12 @@ static int push_refs_with_export(struct transport *transport,
926926
struct strbuf buf = STRBUF_INIT;
927927

928928
if (!data->rs.nr)
929-
die("remote-helper doesn't support push; refspec needed");
929+
die(_("remote-helper doesn't support push; refspec needed"));
930930

931931
set_common_push_options(transport, data->name, flags);
932932
if (flags & TRANSPORT_PUSH_FORCE) {
933933
if (set_helper_option(transport, "force", "true") != 0)
934-
warning("helper %s does not support 'force'", data->name);
934+
warning(_("helper %s does not support 'force'"), data->name);
935935
}
936936

937937
helper = get_helper(transport);
@@ -978,12 +978,12 @@ static int push_refs_with_export(struct transport *transport,
978978
}
979979

980980
if (get_exporter(transport, &exporter, &revlist_args))
981-
die("couldn't run fast-export");
981+
die(_("couldn't run fast-export"));
982982

983983
string_list_clear(&revlist_args, 1);
984984

985985
if (finish_command(&exporter))
986-
die("error while running fast-export");
986+
die(_("error while running fast-export"));
987987
if (push_update_refs_status(data, remote_refs, flags))
988988
return 1;
989989

@@ -1007,8 +1007,9 @@ static int push_refs(struct transport *transport,
10071007
}
10081008

10091009
if (!remote_refs) {
1010-
fprintf(stderr, "No refs in common and none specified; doing nothing.\n"
1011-
"Perhaps you should specify a branch such as 'master'.\n");
1010+
fprintf(stderr,
1011+
_("No refs in common and none specified; doing nothing.\n"
1012+
"Perhaps you should specify a branch such as 'master'.\n"));
10121013
return 0;
10131014
}
10141015

@@ -1070,7 +1071,7 @@ static struct ref *get_refs_list(struct transport *transport, int for_push,
10701071

10711072
eov = strchr(buf.buf, ' ');
10721073
if (!eov)
1073-
die("malformed response in ref list: %s", buf.buf);
1074+
die(_("malformed response in ref list: %s"), buf.buf);
10741075
eon = strchr(eov + 1, ' ');
10751076
*eov = '\0';
10761077
if (eon)
@@ -1223,7 +1224,7 @@ static int udt_do_read(struct unidirectional_transfer *t)
12231224
bytes = read(t->src, t->buf + t->bufuse, BUFFERSIZE - t->bufuse);
12241225
if (bytes < 0 && errno != EWOULDBLOCK && errno != EAGAIN &&
12251226
errno != EINTR) {
1226-
error_errno("read(%s) failed", t->src_name);
1227+
error_errno(_("read(%s) failed"), t->src_name);
12271228
return -1;
12281229
} else if (bytes == 0) {
12291230
transfer_debug("%s EOF (with %i bytes in buffer)",
@@ -1250,7 +1251,7 @@ static int udt_do_write(struct unidirectional_transfer *t)
12501251
transfer_debug("%s is writable", t->dest_name);
12511252
bytes = xwrite(t->dest, t->buf, t->bufuse);
12521253
if (bytes < 0 && errno != EWOULDBLOCK) {
1253-
error_errno("write(%s) failed", t->dest_name);
1254+
error_errno(_("write(%s) failed"), t->dest_name);
12541255
return -1;
12551256
} else if (bytes > 0) {
12561257
t->bufuse -= bytes;
@@ -1299,11 +1300,11 @@ static int tloop_join(pthread_t thread, const char *name)
12991300
void *tret;
13001301
err = pthread_join(thread, &tret);
13011302
if (!tret) {
1302-
error("%s thread failed", name);
1303+
error(_("%s thread failed"), name);
13031304
return 1;
13041305
}
13051306
if (err) {
1306-
error("%s thread failed to join: %s", name, strerror(err));
1307+
error(_("%s thread failed to join: %s"), name, strerror(err));
13071308
return 1;
13081309
}
13091310
return 0;
@@ -1322,11 +1323,11 @@ static int tloop_spawnwait_tasks(struct bidirectional_transfer_state *s)
13221323
err = pthread_create(&gtp_thread, NULL, udt_copy_task_routine,
13231324
&s->gtp);
13241325
if (err)
1325-
die("can't start thread for copying data: %s", strerror(err));
1326+
die(_("can't start thread for copying data: %s"), strerror(err));
13261327
err = pthread_create(&ptg_thread, NULL, udt_copy_task_routine,
13271328
&s->ptg);
13281329
if (err)
1329-
die("can't start thread for copying data: %s", strerror(err));
1330+
die(_("can't start thread for copying data: %s"), strerror(err));
13301331

13311332
ret |= tloop_join(gtp_thread, "Git to program copy");
13321333
ret |= tloop_join(ptg_thread, "Program to git copy");
@@ -1363,11 +1364,11 @@ static int tloop_join(pid_t pid, const char *name)
13631364
{
13641365
int tret;
13651366
if (waitpid(pid, &tret, 0) < 0) {
1366-
error_errno("%s process failed to wait", name);
1367+
error_errno(_("%s process failed to wait"), name);
13671368
return 1;
13681369
}
13691370
if (!WIFEXITED(tret) || WEXITSTATUS(tret)) {
1370-
error("%s process failed", name);
1371+
error(_("%s process failed"), name);
13711372
return 1;
13721373
}
13731374
return 0;
@@ -1385,7 +1386,7 @@ static int tloop_spawnwait_tasks(struct bidirectional_transfer_state *s)
13851386
/* Fork thread #1: git to program. */
13861387
pid1 = fork();
13871388
if (pid1 < 0)
1388-
die_errno("can't start thread for copying data");
1389+
die_errno(_("can't start thread for copying data"));
13891390
else if (pid1 == 0) {
13901391
udt_kill_transfer(&s->ptg);
13911392
exit(udt_copy_task_routine(&s->gtp) ? 0 : 1);
@@ -1394,7 +1395,7 @@ static int tloop_spawnwait_tasks(struct bidirectional_transfer_state *s)
13941395
/* Fork thread #2: program to git. */
13951396
pid2 = fork();
13961397
if (pid2 < 0)
1397-
die_errno("can't start thread for copying data");
1398+
die_errno(_("can't start thread for copying data"));
13981399
else if (pid2 == 0) {
13991400
udt_kill_transfer(&s->gtp);
14001401
exit(udt_copy_task_routine(&s->ptg) ? 0 : 1);

0 commit comments

Comments
 (0)