transport-helper.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 6b5b309f5e1a5b01642c448eff78d5c5332bf340
2 files changed +48 -47
t/t5801-remote-helpers.sh
+4 -4
@@ -126,7 +126,7 @@ test_expect_success 'forced push' '
126 test_expect_success 'cloning without refspec' '
127 GIT_REMOTE_TESTGIT_REFSPEC="" \
128 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 &&
130 compare_refs local2 HEAD server HEAD
131 '
132
@@ -134,7 +134,7 @@ test_expect_success 'pulling without refspecs' '
134 (cd local2 &&
135 git reset --hard &&
136 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 &&
138 compare_refs local2 HEAD server HEAD
139 '
140
@@ -146,7 +146,7 @@ test_expect_success 'pushing without refspecs' '
146 GIT_REMOTE_TESTGIT_REFSPEC="" &&
147 export GIT_REMOTE_TESTGIT_REFSPEC &&
148 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
150 '
151
152 test_expect_success 'pulling without marks' '
@@ -246,7 +246,7 @@ test_expect_success 'proper failure checks for fetching' '
246 (cd local &&
247 test_must_fail env GIT_REMOTE_TESTGIT_FAILURE=1 git fetch 2>error &&
248 cat error &&
249 - grep -q "error while running fast-import" error
249 + test_i18ngrep -q "error while running fast-import" error
250 )
251 '
252
transport-helper.c
+44 -43
@@ -48,7 +48,7 @@ static void sendline(struct helper_data *helper, struct strbuf *buffer)
48 if (debug)
49 fprintf(stderr, "Debug: Remote helper: -> %s", buffer->buf);
50 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"));
52 }
53
54 static int recvline_fh(FILE *helper, struct strbuf *buffer)
@@ -77,7 +77,7 @@ static void write_constant(int fd, const char *str)
77 if (debug)
78 fprintf(stderr, "Debug: Remote helper: -> %s", str);
79 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"));
81 }
82
83 static const char *remove_ext_force(const char *url)
@@ -129,7 +129,7 @@ static struct child_process *get_helper(struct transport *transport)
129
130 code = start_command(helper);
131 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);
133 else if (code != 0)
134 exit(code);
135
@@ -145,7 +145,7 @@ static struct child_process *get_helper(struct transport *transport)
145 */
146 duped = dup(helper->out);
147 if (duped < 0)
148 - die_errno("can't dup helper output fd");
148 + die_errno(_("can't dup helper output fd"));
149 data->out = xfdopen(duped, "r");
150
151 write_constant(helper->in, "capabilities\n");
@@ -196,13 +196,13 @@ static struct child_process *get_helper(struct transport *transport)
196 } else if (starts_with(capname, "no-private-update")) {
197 data->no_private_update = 1;
198 } 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"),
201 capname);
202 }
203 }
204 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"));
206 }
207 strbuf_release(&buf);
208 if (debug)
@@ -269,7 +269,7 @@ static int strbuf_set_helper_option(struct helper_data *data,
269 else if (!strcmp(buf->buf, "unsupported"))
270 ret = 1;
271 else {
272 - warning("%s unexpectedly said: '%s'", data->name, buf->buf);
272 + warning(_("%s unexpectedly said: '%s'"), data->name, buf->buf);
273 ret = 1;
274 }
275 return ret;
@@ -398,7 +398,7 @@ static int fetch_with_fetch(struct transport *transport,
398 if (starts_with(buf.buf, "lock ")) {
399 const char *name = buf.buf + 5;
400 if (transport->pack_lockfile)
401 - warning("%s also locked %s", data->name, name);
401 + warning(_("%s also locked %s"), data->name, name);
402 else
403 transport->pack_lockfile = xstrdup(name);
404 }
@@ -409,7 +409,7 @@ static int fetch_with_fetch(struct transport *transport,
409 else if (!buf.len)
410 break;
411 else
412 - warning("%s unexpectedly said: '%s'", data->name, buf.buf);
412 + warning(_("%s unexpectedly said: '%s'"), data->name, buf.buf);
413 }
414 strbuf_release(&buf);
415 return 0;
@@ -476,7 +476,7 @@ static int fetch_with_import(struct transport *transport,
476 get_helper(transport);
477
478 if (get_importer(transport, &fastimport))
479 - die("couldn't run fast-import");
479 + die(_("couldn't run fast-import"));
480
481 for (i = 0; i < nr_heads; i++) {
482 posn = to_fetch[i];
@@ -499,7 +499,7 @@ static int fetch_with_import(struct transport *transport,
499 */
500
501 if (finish_command(&fastimport))
502 - die("error while running fast-import");
502 + die(_("error while running fast-import"));
503
504 /*
505 * The fast-import stream of a remote helper that advertises
@@ -528,7 +528,7 @@ static int fetch_with_import(struct transport *transport,
528 private = xstrdup(name);
529 if (private) {
530 if (read_ref(private, &posn->old_oid) < 0)
531 - die("could not read ref %s", private);
531 + die(_("could not read ref %s"), private);
532 free(private);
533 }
534 }
@@ -554,7 +554,7 @@ static int run_connect(struct transport *transport, struct strbuf *cmdbuf)
554 */
555 duped = dup(helper->out);
556 if (duped < 0)
557 - die_errno("can't dup helper output fd");
557 + die_errno(_("can't dup helper output fd"));
558 input = xfdopen(duped, "r");
559 setvbuf(input, NULL, _IONBF, 0);
560
@@ -573,8 +573,8 @@ static int run_connect(struct transport *transport, struct strbuf *cmdbuf)
573 fprintf(stderr, "Debug: Falling back to dumb "
574 "transport.\n");
575 } else {
576 - die("unknown response to connect: %s",
577 - cmdbuf->buf);
576 + die(_(_("unknown response to connect: %s")),
577 + cmdbuf->buf);
578 }
579
580 fclose(input);
@@ -595,9 +595,9 @@ static int process_connect_service(struct transport *transport,
595 if (strcmp(name, exec)) {
596 int r = set_helper_option(transport, "servpath", exec);
597 if (r > 0)
598 - warning("setting remote service path not supported by protocol");
598 + warning(_("setting remote service path not supported by protocol"));
599 else if (r < 0)
600 - warning("invalid remote service path");
600 + warning(_("invalid remote service path"));
601 }
602
603 if (data->connect) {
@@ -640,10 +640,10 @@ static int connect_helper(struct transport *transport, const char *name,
640 /* Get_helper so connect is inited. */
641 get_helper(transport);
642 if (!data->connect)
643 - die("operation not supported by protocol");
643 + die(_("operation not supported by protocol"));
644
645 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);
647
648 fd[0] = data->helper->out;
649 fd[1] = data->helper->in;
@@ -707,7 +707,7 @@ static int push_update_ref_status(struct strbuf *buf,
707 status = REF_STATUS_REMOTE_REJECT;
708 refname = buf->buf + 6;
709 } else
710 - die("expected ok/error, helper said '%s'", buf->buf);
710 + die(_("expected ok/error, helper said '%s'"), buf->buf);
711
712 msg = strchr(refname, ' ');
713 if (msg) {
@@ -760,7 +760,7 @@ static int push_update_ref_status(struct strbuf *buf,
760 if (!*ref)
761 *ref = find_ref_by_name(remote_refs, refname);
762 if (!*ref) {
763 - warning("helper reported unexpected status of %s", refname);
763 + warning(_("helper reported unexpected status of %s"), refname);
764 return 1;
765 }
766
@@ -821,20 +821,20 @@ static void set_common_push_options(struct transport *transport,
821 {
822 if (flags & TRANSPORT_PUSH_DRY_RUN) {
823 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);
825 } else if (flags & TRANSPORT_PUSH_CERT_ALWAYS) {
826 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);
828 } else if (flags & TRANSPORT_PUSH_CERT_IF_ASKED) {
829 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);
831 }
832
833 if (flags & TRANSPORT_PUSH_OPTIONS) {
834 struct string_list_item *item;
835 for_each_string_list_item(item, transport->push_options)
836 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);
838 }
839 }
840
@@ -926,12 +926,12 @@ static int push_refs_with_export(struct transport *transport,
926 struct strbuf buf = STRBUF_INIT;
927
928 if (!data->rs.nr)
929 - die("remote-helper doesn't support push; refspec needed");
929 + die(_("remote-helper doesn't support push; refspec needed"));
930
931 set_common_push_options(transport, data->name, flags);
932 if (flags & TRANSPORT_PUSH_FORCE) {
933 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);
935 }
936
937 helper = get_helper(transport);
@@ -978,12 +978,12 @@ static int push_refs_with_export(struct transport *transport,
978 }
979
980 if (get_exporter(transport, &exporter, &revlist_args))
981 - die("couldn't run fast-export");
981 + die(_("couldn't run fast-export"));
982
983 string_list_clear(&revlist_args, 1);
984
985 if (finish_command(&exporter))
986 - die("error while running fast-export");
986 + die(_("error while running fast-export"));
987 if (push_update_refs_status(data, remote_refs, flags))
988 return 1;
989
@@ -1007,8 +1007,9 @@ static int push_refs(struct transport *transport,
1007 }
1008
1009 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"));
1013 return 0;
1014 }
1015
@@ -1070,7 +1071,7 @@ static struct ref *get_refs_list(struct transport *transport, int for_push,
1071
1072 eov = strchr(buf.buf, ' ');
1073 if (!eov)
1073 - die("malformed response in ref list: %s", buf.buf);
1074 + die(_("malformed response in ref list: %s"), buf.buf);
1075 eon = strchr(eov + 1, ' ');
1076 *eov = '\0';
1077 if (eon)
@@ -1223,7 +1224,7 @@ static int udt_do_read(struct unidirectional_transfer *t)
1224 bytes = read(t->src, t->buf + t->bufuse, BUFFERSIZE - t->bufuse);
1225 if (bytes < 0 && errno != EWOULDBLOCK && errno != EAGAIN &&
1226 errno != EINTR) {
1226 - error_errno("read(%s) failed", t->src_name);
1227 + error_errno(_("read(%s) failed"), t->src_name);
1228 return -1;
1229 } else if (bytes == 0) {
1230 transfer_debug("%s EOF (with %i bytes in buffer)",
@@ -1250,7 +1251,7 @@ static int udt_do_write(struct unidirectional_transfer *t)
1251 transfer_debug("%s is writable", t->dest_name);
1252 bytes = xwrite(t->dest, t->buf, t->bufuse);
1253 if (bytes < 0 && errno != EWOULDBLOCK) {
1253 - error_errno("write(%s) failed", t->dest_name);
1254 + error_errno(_("write(%s) failed"), t->dest_name);
1255 return -1;
1256 } else if (bytes > 0) {
1257 t->bufuse -= bytes;
@@ -1299,11 +1300,11 @@ static int tloop_join(pthread_t thread, const char *name)
1300 void *tret;
1301 err = pthread_join(thread, &tret);
1302 if (!tret) {
1302 - error("%s thread failed", name);
1303 + error(_("%s thread failed"), name);
1304 return 1;
1305 }
1306 if (err) {
1306 - error("%s thread failed to join: %s", name, strerror(err));
1307 + error(_("%s thread failed to join: %s"), name, strerror(err));
1308 return 1;
1309 }
1310 return 0;
@@ -1322,11 +1323,11 @@ static int tloop_spawnwait_tasks(struct bidirectional_transfer_state *s)
1323 err = pthread_create(&gtp_thread, NULL, udt_copy_task_routine,
1324 &s->gtp);
1325 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));
1327 err = pthread_create(&ptg_thread, NULL, udt_copy_task_routine,
1328 &s->ptg);
1329 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));
1331
1332 ret |= tloop_join(gtp_thread, "Git to program copy");
1333 ret |= tloop_join(ptg_thread, "Program to git copy");
@@ -1363,11 +1364,11 @@ static int tloop_join(pid_t pid, const char *name)
1364 {
1365 int tret;
1366 if (waitpid(pid, &tret, 0) < 0) {
1366 - error_errno("%s process failed to wait", name);
1367 + error_errno(_("%s process failed to wait"), name);
1368 return 1;
1369 }
1370 if (!WIFEXITED(tret) || WEXITSTATUS(tret)) {
1370 - error("%s process failed", name);
1371 + error(_("%s process failed"), name);
1372 return 1;
1373 }
1374 return 0;
@@ -1385,7 +1386,7 @@ static int tloop_spawnwait_tasks(struct bidirectional_transfer_state *s)
1386 /* Fork thread #1: git to program. */
1387 pid1 = fork();
1388 if (pid1 < 0)
1388 - die_errno("can't start thread for copying data");
1389 + die_errno(_("can't start thread for copying data"));
1390 else if (pid1 == 0) {
1391 udt_kill_transfer(&s->ptg);
1392 exit(udt_copy_task_routine(&s->gtp) ? 0 : 1);
@@ -1394,7 +1395,7 @@ static int tloop_spawnwait_tasks(struct bidirectional_transfer_state *s)
1395 /* Fork thread #2: program to git. */
1396 pid2 = fork();
1397 if (pid2 < 0)
1397 - die_errno("can't start thread for copying data");
1398 + die_errno(_("can't start thread for copying data"));
1399 else if (pid2 == 0) {
1400 udt_kill_transfer(&s->gtp);
1401 exit(udt_copy_task_routine(&s->ptg) ? 0 : 1);