@matheusbsbs / matheus-bagliano / commits / caeba0ef15
Fork 0

i18n: git-notes basic commands

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Ævar Arnfjörð Bjarmason committed Feb 22, 2011 at 23:42 UTC caeba0ef153574d0240020228e0c48807b665a83
1 file changed +53 -53
builtin/notes.c
+53 -53
@@ -146,13 +146,13 @@ static void write_commented_object(int fd, const unsigned char *object)
146 show.err = 0;
147 show.git_cmd = 1;
148 if (start_command(&show))
149 - die("unable to start 'show' for object '%s'",
149 + die(_("unable to start 'show' for object '%s'"),
150 sha1_to_hex(object));
151
152 /* Open the output as FILE* so strbuf_getline() can be used. */
153 show_out = xfdopen(show.out, "r");
154 if (show_out == NULL)
155 - die_errno("can't fdopen 'show' output fd");
155 + die_errno(_("can't fdopen 'show' output fd"));
156
157 /* Prepend "# " to each output line and write result to 'fd' */
158 while (strbuf_getline(&buf, show_out, '\n') != EOF) {
@@ -162,10 +162,10 @@ static void write_commented_object(int fd, const unsigned char *object)
162 }
163 strbuf_release(&buf);
164 if (fclose(show_out))
165 - die_errno("failed to close pipe to 'show' for object '%s'",
165 + die_errno(_("failed to close pipe to 'show' for object '%s'"),
166 sha1_to_hex(object));
167 if (finish_command(&show))
168 - die("failed to finish 'show' for object '%s'",
168 + die(_("failed to finish 'show' for object '%s'"),
169 sha1_to_hex(object));
170 }
171
@@ -182,7 +182,7 @@ static void create_note(const unsigned char *object, struct msg_arg *msg,
182 path = git_pathdup("NOTES_EDITMSG");
183 fd = open(path, O_CREAT | O_TRUNC | O_WRONLY, 0600);
184 if (fd < 0)
185 - die_errno("could not create file '%s'", path);
185 + die_errno(_("could not create file '%s'"), path);
186
187 if (msg->given)
188 write_or_die(fd, msg->buf.buf, msg->buf.len);
@@ -196,8 +196,8 @@ static void create_note(const unsigned char *object, struct msg_arg *msg,
196 strbuf_reset(&(msg->buf));
197
198 if (launch_editor(path, &(msg->buf), NULL)) {
199 - die("Please supply the note contents using either -m" \
200 - " or -F option");
199 + die(_("Please supply the note contents using either -m" \
200 + " or -F option"));
201 }
202 stripspace(&(msg->buf), 1);
203 }
@@ -217,14 +217,14 @@ static void create_note(const unsigned char *object, struct msg_arg *msg,
217 }
218
219 if (!msg->buf.len) {
220 - fprintf(stderr, "Removing note for object %s\n",
220 + fprintf(stderr, _("Removing note for object %s\n"),
221 sha1_to_hex(object));
222 hashclr(result);
223 } else {
224 if (write_sha1_file(msg->buf.buf, msg->buf.len, blob_type, result)) {
225 - error("unable to write note object");
225 + error(_("unable to write note object"));
226 if (path)
227 - error("The note contents has been left in %s",
227 + error(_("The note contents has been left in %s"),
228 path);
229 exit(128);
230 }
@@ -258,9 +258,9 @@ static int parse_file_arg(const struct option *opt, const char *arg, int unset)
258 strbuf_addch(&(msg->buf), '\n');
259 if (!strcmp(arg, "-")) {
260 if (strbuf_read(&(msg->buf), 0, 1024) < 0)
261 - die_errno("cannot read '%s'", arg);
261 + die_errno(_("cannot read '%s'"), arg);
262 } else if (strbuf_read_file(&(msg->buf), arg, 1024) < 0)
263 - die_errno("could not open or read '%s'", arg);
263 + die_errno(_("could not open or read '%s'"), arg);
264 stripspace(&(msg->buf), 0);
265
266 msg->given = 1;
@@ -279,10 +279,10 @@ static int parse_reuse_arg(const struct option *opt, const char *arg, int unset)
279 strbuf_addch(&(msg->buf), '\n');
280
281 if (get_sha1(arg, object))
282 - die("Failed to resolve '%s' as a valid ref.", arg);
282 + die(_("Failed to resolve '%s' as a valid ref."), arg);
283 if (!(buf = read_sha1_file(object, &type, &len)) || !len) {
284 free(buf);
285 - die("Failed to read object '%s'.", arg);;
285 + die(_("Failed to read object '%s'."), arg);;
286 }
287 strbuf_add(&(msg->buf), buf, len);
288 free(buf);
@@ -306,7 +306,7 @@ void commit_notes(struct notes_tree *t, const char *msg)
306 if (!t)
307 t = &default_notes_tree;
308 if (!t->initialized || !t->ref || !*t->ref)
309 - die("Cannot commit uninitialized/unreferenced notes tree");
309 + die(_("Cannot commit uninitialized/unreferenced notes tree"));
310 if (!t->dirty)
311 return; /* don't have to commit an unchanged tree */
312
@@ -347,7 +347,7 @@ static int notes_rewrite_config(const char *k, const char *v, void *cb)
347 config_error_nonbool(k);
348 c->combine = parse_combine_notes_fn(v);
349 if (!c->combine) {
350 - error("Bad notes.rewriteMode value: '%s'", v);
350 + error(_("Bad notes.rewriteMode value: '%s'"), v);
351 return 1;
352 }
353 return 0;
@@ -357,8 +357,8 @@ static int notes_rewrite_config(const char *k, const char *v, void *cb)
357 if (!prefixcmp(v, "refs/notes/"))
358 string_list_add_refs_by_glob(c->refs, v);
359 else
360 - warning("Refusing to rewrite notes in %s"
361 - " (outside of refs/notes/)", v);
360 + warning(_("Refusing to rewrite notes in %s"
361 + " (outside of refs/notes/)"), v);
362 return 0;
363 }
364
@@ -446,13 +446,13 @@ int notes_copy_from_stdin(int force, const char *rewrite_cmd)
446
447 split = strbuf_split(&buf, ' ');
448 if (!split[0] || !split[1])
449 - die("Malformed input line: '%s'.", buf.buf);
449 + die(_("Malformed input line: '%s'."), buf.buf);
450 strbuf_rtrim(split[0]);
451 strbuf_rtrim(split[1]);
452 if (get_sha1(split[0]->buf, from_obj))
453 - die("Failed to resolve '%s' as a valid ref.", split[0]->buf);
453 + die(_("Failed to resolve '%s' as a valid ref."), split[0]->buf);
454 if (get_sha1(split[1]->buf, to_obj))
455 - die("Failed to resolve '%s' as a valid ref.", split[1]->buf);
455 + die(_("Failed to resolve '%s' as a valid ref."), split[1]->buf);
456
457 if (rewrite_cmd)
458 err = copy_note_for_rewrite(c, from_obj, to_obj);
@@ -461,7 +461,7 @@ int notes_copy_from_stdin(int force, const char *rewrite_cmd)
461 combine_notes_overwrite);
462
463 if (err) {
464 - error("Failed to copy notes from '%s' to '%s'",
464 + error(_("Failed to copy notes from '%s' to '%s'"),
465 split[0]->buf, split[1]->buf);
466 ret = 1;
467 }
@@ -505,20 +505,20 @@ static int list(int argc, const char **argv, const char *prefix)
505 git_notes_list_usage, 0);
506
507 if (1 < argc) {
508 - error("too many parameters");
508 + error(_("too many parameters"));
509 usage_with_options(git_notes_list_usage, options);
510 }
511
512 t = init_notes_check("list");
513 if (argc) {
514 if (get_sha1(argv[0], object))
515 - die("Failed to resolve '%s' as a valid ref.", argv[0]);
515 + die(_("Failed to resolve '%s' as a valid ref."), argv[0]);
516 note = get_note(t, object);
517 if (note) {
518 puts(sha1_to_hex(note));
519 retval = 0;
520 } else
521 - retval = error("No note found for object %s.",
521 + retval = error(_("No note found for object %s."),
522 sha1_to_hex(object));
523 } else
524 retval = for_each_note(t, 0, list_each_note, NULL);
@@ -557,26 +557,26 @@ static int add(int argc, const char **argv, const char *prefix)
557 0);
558
559 if (1 < argc) {
560 - error("too many parameters");
560 + error(_("too many parameters"));
561 usage_with_options(git_notes_add_usage, options);
562 }
563
564 object_ref = argc ? argv[0] : "HEAD";
565
566 if (get_sha1(object_ref, object))
567 - die("Failed to resolve '%s' as a valid ref.", object_ref);
567 + die(_("Failed to resolve '%s' as a valid ref."), object_ref);
568
569 t = init_notes_check("add");
570 note = get_note(t, object);
571
572 if (note) {
573 if (!force) {
574 - retval = error("Cannot add notes. Found existing notes "
574 + retval = error(_("Cannot add notes. Found existing notes "
575 "for object %s. Use '-f' to overwrite "
576 - "existing notes", sha1_to_hex(object));
576 + "existing notes"), sha1_to_hex(object));
577 goto out;
578 }
579 - fprintf(stderr, "Overwriting existing notes for object %s\n",
579 + fprintf(stderr, _("Overwriting existing notes for object %s\n"),
580 sha1_to_hex(object));
581 }
582
@@ -618,7 +618,7 @@ static int copy(int argc, const char **argv, const char *prefix)
618
619 if (from_stdin || rewrite_cmd) {
620 if (argc) {
621 - error("too many parameters");
621 + error(_("too many parameters"));
622 usage_with_options(git_notes_copy_usage, options);
623 } else {
624 return notes_copy_from_stdin(force, rewrite_cmd);
@@ -626,41 +626,41 @@ static int copy(int argc, const char **argv, const char *prefix)
626 }
627
628 if (argc < 2) {
629 - error("too few parameters");
629 + error(_("too few parameters"));
630 usage_with_options(git_notes_copy_usage, options);
631 }
632 if (2 < argc) {
633 - error("too many parameters");
633 + error(_("too many parameters"));
634 usage_with_options(git_notes_copy_usage, options);
635 }
636
637 if (get_sha1(argv[0], from_obj))
638 - die("Failed to resolve '%s' as a valid ref.", argv[0]);
638 + die(_("Failed to resolve '%s' as a valid ref."), argv[0]);
639
640 object_ref = 1 < argc ? argv[1] : "HEAD";
641
642 if (get_sha1(object_ref, object))
643 - die("Failed to resolve '%s' as a valid ref.", object_ref);
643 + die(_("Failed to resolve '%s' as a valid ref."), object_ref);
644
645 t = init_notes_check("copy");
646 note = get_note(t, object);
647
648 if (note) {
649 if (!force) {
650 - retval = error("Cannot copy notes. Found existing "
650 + retval = error(_("Cannot copy notes. Found existing "
651 "notes for object %s. Use '-f' to "
652 - "overwrite existing notes",
652 + "overwrite existing notes"),
653 sha1_to_hex(object));
654 goto out;
655 }
656 - fprintf(stderr, "Overwriting existing notes for object %s\n",
656 + fprintf(stderr, _("Overwriting existing notes for object %s\n"),
657 sha1_to_hex(object));
658 }
659
660 from_note = get_note(t, from_obj);
661 if (!from_note) {
662 - retval = error("Missing notes on source object %s. Cannot "
663 - "copy.", sha1_to_hex(from_obj));
662 + retval = error(_("Missing notes on source object %s. Cannot "
663 + "copy."), sha1_to_hex(from_obj));
664 goto out;
665 }
666
@@ -703,19 +703,19 @@ static int append_edit(int argc, const char **argv, const char *prefix)
703 PARSE_OPT_KEEP_ARGV0);
704
705 if (2 < argc) {
706 - error("too many parameters");
706 + error(_("too many parameters"));
707 usage_with_options(usage, options);
708 }
709
710 if (msg.given && edit)
711 - fprintf(stderr, "The -m/-F/-c/-C options have been deprecated "
711 + fprintf(stderr, _("The -m/-F/-c/-C options have been deprecated "
712 "for the 'edit' subcommand.\n"
713 - "Please use 'git notes add -f -m/-F/-c/-C' instead.\n");
713 + "Please use 'git notes add -f -m/-F/-c/-C' instead.\n"));
714
715 object_ref = 1 < argc ? argv[1] : "HEAD";
716
717 if (get_sha1(object_ref, object))
718 - die("Failed to resolve '%s' as a valid ref.", object_ref);
718 + die(_("Failed to resolve '%s' as a valid ref."), object_ref);
719
720 t = init_notes_check(argv[0]);
721 note = get_note(t, object);
@@ -750,20 +750,20 @@ static int show(int argc, const char **argv, const char *prefix)
750 0);
751
752 if (1 < argc) {
753 - error("too many parameters");
753 + error(_("too many parameters"));
754 usage_with_options(git_notes_show_usage, options);
755 }
756
757 object_ref = argc ? argv[0] : "HEAD";
758
759 if (get_sha1(object_ref, object))
760 - die("Failed to resolve '%s' as a valid ref.", object_ref);
760 + die(_("Failed to resolve '%s' as a valid ref."), object_ref);
761
762 t = init_notes_check("show");
763 note = get_note(t, object);
764
765 if (!note)
766 - retval = error("No note found for object %s.",
766 + retval = error(_("No note found for object %s."),
767 sha1_to_hex(object));
768 else {
769 const char *show_args[3] = {"show", sha1_to_hex(note), NULL};
@@ -961,22 +961,22 @@ static int remove_cmd(int argc, const char **argv, const char *prefix)
961 git_notes_remove_usage, 0);
962
963 if (1 < argc) {
964 - error("too many parameters");
964 + error(_("too many parameters"));
965 usage_with_options(git_notes_remove_usage, options);
966 }
967
968 object_ref = argc ? argv[0] : "HEAD";
969
970 if (get_sha1(object_ref, object))
971 - die("Failed to resolve '%s' as a valid ref.", object_ref);
971 + die(_("Failed to resolve '%s' as a valid ref."), object_ref);
972
973 t = init_notes_check("remove");
974
975 retval = remove_note(t, object);
976 if (retval)
977 - fprintf(stderr, "Object %s has no note\n", sha1_to_hex(object));
977 + fprintf(stderr, _("Object %s has no note\n"), sha1_to_hex(object));
978 else {
979 - fprintf(stderr, "Removing note for object %s\n",
979 + fprintf(stderr, _("Removing note for object %s\n"),
980 sha1_to_hex(object));
981
982 commit_notes(t, "Notes removed by 'git notes remove'");
@@ -999,7 +999,7 @@ static int prune(int argc, const char **argv, const char *prefix)
999 0);
1000
1001 if (argc) {
1002 - error("too many parameters");
1002 + error(_("too many parameters"));
1003 usage_with_options(git_notes_prune_usage, options);
1004 }
1005
@@ -1069,7 +1069,7 @@ int cmd_notes(int argc, const char **argv, const char *prefix)
1069 else if (!strcmp(argv[0], "get-ref"))
1070 result = get_ref(argc, argv, prefix);
1071 else {
1072 - result = error("Unknown subcommand: %s", argv[0]);
1072 + result = error(_("Unknown subcommand: %s"), argv[0]);
1073 usage_with_options(git_notes_usage, options);
1074 }
1075