builtin/replace.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 225c62e0671f3d487cefcbb4976355e8e46a531a
1 file changed +37 -37
builtin/replace.c
+37 -37
@@ -54,7 +54,7 @@ static int show_reference(const char *refname, const struct object_id *oid,
54 enum object_type obj_type, repl_type;
55
56 if (get_oid(refname, &object))
57 - return error("failed to resolve '%s' as a valid ref", refname);
57 + return error(_("failed to resolve '%s' as a valid ref"), refname);
58
59 obj_type = oid_object_info(the_repository, &object,
60 NULL);
@@ -83,8 +83,8 @@ static int list_replace_refs(const char *pattern, const char *format)
83 else if (!strcmp(format, "long"))
84 data.format = REPLACE_FORMAT_LONG;
85 else
86 - return error("invalid replace format '%s'\n"
87 - "valid formats are 'short', 'medium' and 'long'",
86 + return error(_("invalid replace format '%s'\n"
87 + "valid formats are 'short', 'medium' and 'long'"),
88 format);
89
90 for_each_replace_ref(the_repository, show_reference, (void *)&data);
@@ -118,7 +118,7 @@ static int for_each_replace_name(const char **argv, each_replace_name_fn fn)
118 full_hex = ref.buf + base_len;
119
120 if (read_ref(ref.buf, &oid)) {
121 - error("replace ref '%s' not found", full_hex);
121 + error(_("replace ref '%s' not found"), full_hex);
122 had_error = 1;
123 continue;
124 }
@@ -134,7 +134,7 @@ static int delete_replace_ref(const char *name, const char *ref,
134 {
135 if (delete_ref(NULL, ref, oid, 0))
136 return 1;
137 - printf_ln("Deleted replace ref '%s'", name);
137 + printf_ln(_("Deleted replace ref '%s'"), name);
138 return 0;
139 }
140
@@ -146,12 +146,12 @@ static int check_ref_valid(struct object_id *object,
146 strbuf_reset(ref);
147 strbuf_addf(ref, "%s%s", git_replace_ref_base, oid_to_hex(object));
148 if (check_refname_format(ref->buf, 0))
149 - return error("'%s' is not a valid ref name", ref->buf);
149 + return error(_("'%s' is not a valid ref name"), ref->buf);
150
151 if (read_ref(ref->buf, prev))
152 oidclr(prev);
153 else if (!force)
154 - return error("replace ref '%s' already exists", ref->buf);
154 + return error(_("replace ref '%s' already exists"), ref->buf);
155 return 0;
156 }
157
@@ -171,10 +171,10 @@ static int replace_object_oid(const char *object_ref,
171 obj_type = oid_object_info(the_repository, object, NULL);
172 repl_type = oid_object_info(the_repository, repl, NULL);
173 if (!force && obj_type != repl_type)
174 - return error("Objects must be of the same type.\n"
175 - "'%s' points to a replaced object of type '%s'\n"
176 - "while '%s' points to a replacement object of "
177 - "type '%s'.",
174 + return error(_("Objects must be of the same type.\n"
175 + "'%s' points to a replaced object of type '%s'\n"
176 + "while '%s' points to a replacement object of "
177 + "type '%s'."),
178 object_ref, type_name(obj_type),
179 replace_ref, type_name(repl_type));
180
@@ -200,10 +200,10 @@ static int replace_object(const char *object_ref, const char *replace_ref, int f
200 struct object_id object, repl;
201
202 if (get_oid(object_ref, &object))
203 - return error("failed to resolve '%s' as a valid ref",
203 + return error(_("failed to resolve '%s' as a valid ref"),
204 object_ref);
205 if (get_oid(replace_ref, &repl))
206 - return error("failed to resolve '%s' as a valid ref",
206 + return error(_("failed to resolve '%s' as a valid ref"),
207 replace_ref);
208
209 return replace_object_oid(object_ref, &object, replace_ref, &repl, force);
@@ -222,7 +222,7 @@ static int export_object(const struct object_id *oid, enum object_type type,
222
223 fd = open(filename, O_WRONLY | O_CREAT | O_TRUNC, 0666);
224 if (fd < 0)
225 - return error_errno("unable to open %s for writing", filename);
225 + return error_errno(_("unable to open %s for writing"), filename);
226
227 argv_array_push(&cmd.args, "--no-replace-objects");
228 argv_array_push(&cmd.args, "cat-file");
@@ -235,7 +235,7 @@ static int export_object(const struct object_id *oid, enum object_type type,
235 cmd.out = fd;
236
237 if (run_command(&cmd))
238 - return error("cat-file reported failure");
238 + return error(_("cat-file reported failure"));
239 return 0;
240 }
241
@@ -251,7 +251,7 @@ static int import_object(struct object_id *oid, enum object_type type,
251
252 fd = open(filename, O_RDONLY);
253 if (fd < 0)
254 - return error_errno("unable to open %s for reading", filename);
254 + return error_errno(_("unable to open %s for reading"), filename);
255
256 if (!raw && type == OBJ_TREE) {
257 const char *argv[] = { "mktree", NULL };
@@ -265,11 +265,11 @@ static int import_object(struct object_id *oid, enum object_type type,
265
266 if (start_command(&cmd)) {
267 close(fd);
268 - return error("unable to spawn mktree");
268 + return error(_("unable to spawn mktree"));
269 }
270
271 if (strbuf_read(&result, cmd.out, 41) < 0) {
272 - error_errno("unable to read from mktree");
272 + error_errno(_("unable to read from mktree"));
273 close(fd);
274 close(cmd.out);
275 return -1;
@@ -278,11 +278,11 @@ static int import_object(struct object_id *oid, enum object_type type,
278
279 if (finish_command(&cmd)) {
280 strbuf_release(&result);
281 - return error("mktree reported failure");
281 + return error(_("mktree reported failure"));
282 }
283 if (get_oid_hex(result.buf, oid) < 0) {
284 strbuf_release(&result);
285 - return error("mktree did not return an object name");
285 + return error(_("mktree did not return an object name"));
286 }
287
288 strbuf_release(&result);
@@ -291,12 +291,12 @@ static int import_object(struct object_id *oid, enum object_type type,
291 int flags = HASH_FORMAT_CHECK | HASH_WRITE_OBJECT;
292
293 if (fstat(fd, &st) < 0) {
294 - error_errno("unable to fstat %s", filename);
294 + error_errno(_("unable to fstat %s"), filename);
295 close(fd);
296 return -1;
297 }
298 if (index_fd(oid, fd, &st, type, NULL, flags) < 0)
299 - return error("unable to write object to database");
299 + return error(_("unable to write object to database"));
300 /* index_fd close()s fd for us */
301 }
302
@@ -315,11 +315,11 @@ static int edit_and_replace(const char *object_ref, int force, int raw)
315 struct strbuf ref = STRBUF_INIT;
316
317 if (get_oid(object_ref, &old_oid) < 0)
318 - return error("not a valid object name: '%s'", object_ref);
318 + return error(_("not a valid object name: '%s'"), object_ref);
319
320 type = oid_object_info(the_repository, &old_oid, NULL);
321 if (type < 0)
322 - return error("unable to get object type for %s",
322 + return error(_("unable to get object type for %s"),
323 oid_to_hex(&old_oid));
324
325 if (check_ref_valid(&old_oid, &prev, &ref, force)) {
@@ -335,7 +335,7 @@ static int edit_and_replace(const char *object_ref, int force, int raw)
335 }
336 if (launch_editor(tmpfile, NULL, NULL) < 0) {
337 free(tmpfile);
338 - return error("editing object file failed");
338 + return error(_("editing object file failed"));
339 }
340 if (import_object(&new_oid, type, raw, tmpfile)) {
341 free(tmpfile);
@@ -344,7 +344,7 @@ static int edit_and_replace(const char *object_ref, int force, int raw)
344 free(tmpfile);
345
346 if (!oidcmp(&old_oid, &new_oid))
347 - return error("new object is the same as the old one: '%s'", oid_to_hex(&old_oid));
347 + return error(_("new object is the same as the old one: '%s'"), oid_to_hex(&old_oid));
348
349 return replace_object_oid(object_ref, &old_oid, "replacement", &new_oid, force);
350 }
@@ -476,10 +476,10 @@ static int create_graft(int argc, const char **argv, int force, int gentle)
476
477 if (!oidcmp(&old_oid, &new_oid)) {
478 if (gentle) {
479 - warning("graft for '%s' unnecessary", oid_to_hex(&old_oid));
479 + warning(_("graft for '%s' unnecessary"), oid_to_hex(&old_oid));
480 return 0;
481 }
482 - return error("new commit is the same as the old one: '%s'", oid_to_hex(&old_oid));
482 + return error(_("new commit is the same as the old one: '%s'"), oid_to_hex(&old_oid));
483 }
484
485 return replace_object_oid(old_ref, &old_oid, "replacement", &new_oid, force);
@@ -553,7 +553,7 @@ int cmd_replace(int argc, const char **argv, const char *prefix)
553 cmdmode = argc ? MODE_REPLACE : MODE_LIST;
554
555 if (format && cmdmode != MODE_LIST)
556 - usage_msg_opt("--format cannot be used when not listing",
556 + usage_msg_opt(_("--format cannot be used when not listing"),
557 git_replace_usage, options);
558
559 if (force &&
@@ -561,47 +561,47 @@ int cmd_replace(int argc, const char **argv, const char *prefix)
561 cmdmode != MODE_EDIT &&
562 cmdmode != MODE_GRAFT &&
563 cmdmode != MODE_CONVERT_GRAFT_FILE)
564 - usage_msg_opt("-f only makes sense when writing a replacement",
564 + usage_msg_opt(_("-f only makes sense when writing a replacement"),
565 git_replace_usage, options);
566
567 if (raw && cmdmode != MODE_EDIT)
568 - usage_msg_opt("--raw only makes sense with --edit",
568 + usage_msg_opt(_("--raw only makes sense with --edit"),
569 git_replace_usage, options);
570
571 switch (cmdmode) {
572 case MODE_DELETE:
573 if (argc < 1)
574 - usage_msg_opt("-d needs at least one argument",
574 + usage_msg_opt(_("-d needs at least one argument"),
575 git_replace_usage, options);
576 return for_each_replace_name(argv, delete_replace_ref);
577
578 case MODE_REPLACE:
579 if (argc != 2)
580 - usage_msg_opt("bad number of arguments",
580 + usage_msg_opt(_("bad number of arguments"),
581 git_replace_usage, options);
582 return replace_object(argv[0], argv[1], force);
583
584 case MODE_EDIT:
585 if (argc != 1)
586 - usage_msg_opt("-e needs exactly one argument",
586 + usage_msg_opt(_("-e needs exactly one argument"),
587 git_replace_usage, options);
588 return edit_and_replace(argv[0], force, raw);
589
590 case MODE_GRAFT:
591 if (argc < 1)
592 - usage_msg_opt("-g needs at least one argument",
592 + usage_msg_opt(_("-g needs at least one argument"),
593 git_replace_usage, options);
594 return create_graft(argc, argv, force, 0);
595
596 case MODE_CONVERT_GRAFT_FILE:
597 if (argc != 0)
598 - usage_msg_opt("--convert-graft-file takes no argument",
598 + usage_msg_opt(_("--convert-graft-file takes no argument"),
599 git_replace_usage, options);
600 return !!convert_graft_file(force);
601
602 case MODE_LIST:
603 if (argc > 1)
604 - usage_msg_opt("only one pattern can be given with -l",
604 + usage_msg_opt(_("only one pattern can be given with -l"),
605 git_replace_usage, options);
606 return list_replace_refs(argv[0], format);
607