fast-export: mark strings for translation
Some error or warning messages in "builtin/fast-export.c" are marked for translation, but many are not. To be more consistent and provide a better experience to people using a translated version, let's mark all the remaining error or warning messages for translation. While at it: - improve how some arguments to some error functions are indented, - remove "Error:" at the start of an error message, - downcase error and warning messages that start with an uppercase. Signed-off-by: Christian Couder <chriscool@tuxfamily.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Christian Couder committed
Oct 30, 2025 at 13:33 UTC
d53287b734cd24d40b1509d77741a59eb5564764
1 file changed
+40
-39
builtin/fast-export.c
+40
-39
@@ -65,7 +65,7 @@ static int parse_opt_sign_mode(const struct option *opt,
65
return 0;
66
67
if (parse_sign_mode(arg, val))
68
- return error("Unknown %s mode: %s", opt->long_name, arg);
68
+ return error(_("unknown %s mode: %s"), opt->long_name, arg);
69
70
return 0;
71
}
@@ -82,7 +82,7 @@ static int parse_opt_tag_of_filtered_mode(const struct option *opt,
82
else if (!strcmp(arg, "rewrite"))
83
*val = REWRITE;
84
else
85
- return error("Unknown tag-of-filtered mode: %s", arg);
85
+ return error(_("unknown tag-of-filtered mode: %s"), arg);
86
return 0;
87
}
88
@@ -107,7 +107,7 @@ static int parse_opt_reencode_mode(const struct option *opt,
107
if (!strcasecmp(arg, "abort"))
108
*val = REENCODE_ABORT;
109
else
110
- return error("Unknown reencoding mode: %s", arg);
110
+ return error(_("unknown reencoding mode: %s"), arg);
111
}
112
113
return 0;
@@ -318,16 +318,16 @@ static void export_blob(const struct object_id *oid)
318
} else {
319
buf = odb_read_object(the_repository->objects, oid, &type, &size);
320
if (!buf)
321
- die("could not read blob %s", oid_to_hex(oid));
321
+ die(_("could not read blob %s"), oid_to_hex(oid));
322
if (check_object_signature(the_repository, oid, buf, size,
323
type) < 0)
324
- die("oid mismatch in blob %s", oid_to_hex(oid));
324
+ die(_("oid mismatch in blob %s"), oid_to_hex(oid));
325
object = parse_object_buffer(the_repository, oid, type,
326
size, buf, &eaten);
327
}
328
329
if (!object)
330
- die("Could not read blob %s", oid_to_hex(oid));
330
+ die(_("could not read blob %s"), oid_to_hex(oid));
331
332
mark_next_object(object);
333
@@ -336,7 +336,7 @@ static void export_blob(const struct object_id *oid)
336
printf("original-oid %s\n", oid_to_hex(oid));
337
printf("data %"PRIuMAX"\n", (uintmax_t)size);
338
if (size && fwrite(buf, size, 1, stdout) != 1)
339
- die_errno("could not write blob '%s'", oid_to_hex(oid));
339
+ die_errno(_("could not write blob '%s'"), oid_to_hex(oid));
340
printf("\n");
341
342
show_progress();
@@ -499,10 +499,10 @@ static void show_filemodify(struct diff_queue_struct *q,
499
break;
500
501
default:
502
- die("Unexpected comparison status '%c' for %s, %s",
503
- q->queue[i]->status,
504
- ospec->path ? ospec->path : "none",
505
- spec->path ? spec->path : "none");
502
+ die(_("unexpected comparison status '%c' for %s, %s"),
503
+ q->queue[i]->status,
504
+ ospec->path ? ospec->path : _("none"),
505
+ spec->path ? spec->path : _("none"));
506
}
507
}
508
}
@@ -699,14 +699,14 @@ static void handle_commit(struct commit *commit, struct rev_info *rev,
699
700
author = strstr(commit_buffer_cursor, "\nauthor ");
701
if (!author)
702
- die("could not find author in commit %s",
702
+ die(_("could not find author in commit %s"),
703
oid_to_hex(&commit->object.oid));
704
author++;
705
commit_buffer_cursor = author_end = strchrnul(author, '\n');
706
707
committer = strstr(commit_buffer_cursor, "\ncommitter ");
708
if (!committer)
709
- die("could not find committer in commit %s",
709
+ die(_("could not find committer in commit %s"),
710
oid_to_hex(&commit->object.oid));
711
committer++;
712
commit_buffer_cursor = committer_end = strchrnul(committer, '\n');
@@ -781,8 +781,8 @@ static void handle_commit(struct commit *commit, struct rev_info *rev,
781
case REENCODE_NO:
782
break;
783
case REENCODE_ABORT:
784
- die("Encountered commit-specific encoding %.*s in commit "
785
- "%s; use --reencode=[yes|no] to handle it",
784
+ die(_("encountered commit-specific encoding %.*s in commit "
785
+ "%s; use --reencode=[yes|no] to handle it"),
786
(int)encoding_len, encoding,
787
oid_to_hex(&commit->object.oid));
788
}
@@ -798,11 +798,11 @@ static void handle_commit(struct commit *commit, struct rev_info *rev,
798
if (signatures.nr) {
799
switch (signed_commit_mode) {
800
case SIGN_ABORT:
801
- die("encountered signed commit %s; use "
802
- "--signed-commits=<mode> to handle it",
801
+ die(_("encountered signed commit %s; use "
802
+ "--signed-commits=<mode> to handle it"),
803
oid_to_hex(&commit->object.oid));
804
case SIGN_WARN_VERBATIM:
805
- warning("exporting %"PRIuMAX" signature(s) for commit %s",
805
+ warning(_("exporting %"PRIuMAX" signature(s) for commit %s"),
806
(uintmax_t)signatures.nr, oid_to_hex(&commit->object.oid));
807
/* fallthru */
808
case SIGN_VERBATIM:
@@ -812,7 +812,7 @@ static void handle_commit(struct commit *commit, struct rev_info *rev,
812
}
813
break;
814
case SIGN_WARN_STRIP:
815
- warning("stripping signature(s) from commit %s",
815
+ warning(_("stripping signature(s) from commit %s"),
816
oid_to_hex(&commit->object.oid));
817
/* fallthru */
818
case SIGN_STRIP:
@@ -890,7 +890,8 @@ static void handle_tag(const char *name, struct tag *tag)
890
tagged = ((struct tag *)tagged)->tagged;
891
}
892
if (tagged->type == OBJ_TREE) {
893
- warning("Omitting tag %s,\nsince tags of trees (or tags of tags of trees, etc.) are not supported.",
893
+ warning(_("omitting tag %s,\nsince tags of trees (or tags "
894
+ "of tags of trees, etc.) are not supported."),
895
oid_to_hex(&tag->object.oid));
896
return;
897
}
@@ -898,7 +899,7 @@ static void handle_tag(const char *name, struct tag *tag)
899
buf = odb_read_object(the_repository->objects, &tag->object.oid,
900
&type, &size);
901
if (!buf)
901
- die("could not read tag %s", oid_to_hex(&tag->object.oid));
902
+ die(_("could not read tag %s"), oid_to_hex(&tag->object.oid));
903
message = memmem(buf, size, "\n\n", 2);
904
if (message) {
905
message += 2;
@@ -936,17 +937,17 @@ static void handle_tag(const char *name, struct tag *tag)
937
if (signature)
938
switch (signed_tag_mode) {
939
case SIGN_ABORT:
939
- die("encountered signed tag %s; use "
940
- "--signed-tags=<mode> to handle it",
940
+ die(_("encountered signed tag %s; use "
941
+ "--signed-tags=<mode> to handle it"),
942
oid_to_hex(&tag->object.oid));
943
case SIGN_WARN_VERBATIM:
943
- warning("exporting signed tag %s",
944
+ warning(_("exporting signed tag %s"),
945
oid_to_hex(&tag->object.oid));
946
/* fallthru */
947
case SIGN_VERBATIM:
948
break;
949
case SIGN_WARN_STRIP:
949
- warning("stripping signature from tag %s",
950
+ warning(_("stripping signature from tag %s"),
951
oid_to_hex(&tag->object.oid));
952
/* fallthru */
953
case SIGN_STRIP:
@@ -961,8 +962,8 @@ static void handle_tag(const char *name, struct tag *tag)
962
if (!tagged_mark) {
963
switch (tag_of_filtered_mode) {
964
case TAG_FILTERING_ABORT:
964
- die("tag %s tags unexported object; use "
965
- "--tag-of-filtered-object=<mode> to handle it",
965
+ die(_("tag %s tags unexported object; use "
966
+ "--tag-of-filtered-object=<mode> to handle it"),
967
oid_to_hex(&tag->object.oid));
968
case DROP:
969
/* Ignore this tag altogether */
@@ -970,7 +971,7 @@ static void handle_tag(const char *name, struct tag *tag)
971
return;
972
case REWRITE:
973
if (tagged->type == OBJ_TAG && !mark_tags) {
973
- die(_("Error: Cannot export nested tags unless --mark-tags is specified."));
974
+ die(_("cannot export nested tags unless --mark-tags is specified."));
975
} else if (tagged->type == OBJ_COMMIT) {
976
p = rewrite_commit((struct commit *)tagged);
977
if (!p) {
@@ -1026,7 +1027,7 @@ static struct commit *get_commit(struct rev_cmdline_entry *e, const char *full_n
1027
tag = (struct tag *)tag->tagged;
1028
}
1029
if (!tag)
1029
- die("Tag %s points nowhere?", e->name);
1030
+ die(_("tag %s points nowhere?"), e->name);
1031
return (struct commit *)tag;
1032
}
1033
default:
@@ -1064,7 +1065,7 @@ static void get_tags_and_duplicates(struct rev_cmdline_info *info)
1065
1066
commit = get_commit(e, full_name);
1067
if (!commit) {
1067
- warning("%s: Unexpected object of type %s, skipping.",
1068
+ warning(_("%s: unexpected object of type %s, skipping."),
1069
e->name,
1070
type_name(e->item->type));
1071
free(full_name);
@@ -1079,7 +1080,7 @@ static void get_tags_and_duplicates(struct rev_cmdline_info *info)
1080
free(full_name);
1081
continue;
1082
default: /* OBJ_TAG (nested tags) is already handled */
1082
- warning("Tag points to object of unexpected type %s, skipping.",
1083
+ warning(_("tag points to object of unexpected type %s, skipping."),
1084
type_name(commit->object.type));
1085
free(full_name);
1086
continue;
@@ -1175,7 +1176,7 @@ static void export_marks(char *file)
1176
1177
f = fopen_for_writing(file);
1178
if (!f)
1178
- die_errno("Unable to open marks file %s for writing.", file);
1179
+ die_errno(_("unable to open marks file %s for writing."), file);
1180
1181
for (i = 0; i < idnums.size; i++) {
1182
if (deco->base && deco->base->type == 1) {
@@ -1192,7 +1193,7 @@ static void export_marks(char *file)
1193
e |= ferror(f);
1194
e |= fclose(f);
1195
if (e)
1195
- error("Unable to write marks file %s.", file);
1196
+ error(_("unable to write marks file %s."), file);
1197
}
1198
1199
static void import_marks(char *input_file, int check_exists)
@@ -1215,20 +1216,20 @@ static void import_marks(char *input_file, int check_exists)
1216
1217
line_end = strchr(line, '\n');
1218
if (line[0] != ':' || !line_end)
1218
- die("corrupt mark line: %s", line);
1219
+ die(_("corrupt mark line: %s"), line);
1220
*line_end = '\0';
1221
1222
mark = strtoumax(line + 1, &mark_end, 10);
1223
if (!mark || mark_end == line + 1
1224
|| *mark_end != ' ' || get_oid_hex(mark_end + 1, &oid))
1224
- die("corrupt mark line: %s", line);
1225
+ die(_("corrupt mark line: %s"), line);
1226
1227
if (last_idnum < mark)
1228
last_idnum = mark;
1229
1230
type = odb_read_object_info(the_repository->objects, &oid, NULL);
1231
if (type < 0)
1231
- die("object not found: %s", oid_to_hex(&oid));
1232
+ die(_("object not found: %s"), oid_to_hex(&oid));
1233
1234
if (type != OBJ_COMMIT)
1235
/* only commits */
@@ -1236,12 +1237,12 @@ static void import_marks(char *input_file, int check_exists)
1237
1238
commit = lookup_commit(the_repository, &oid);
1239
if (!commit)
1239
- die("not a commit? can't happen: %s", oid_to_hex(&oid));
1240
+ die(_("not a commit? can't happen: %s"), oid_to_hex(&oid));
1241
1242
object = &commit->object;
1243
1244
if (object->flags & SHOWN)
1244
- error("Object %s already has a mark", oid_to_hex(&oid));
1245
+ error(_("object %s already has a mark"), oid_to_hex(&oid));
1246
1247
mark_object(object, mark);
1248
@@ -1395,7 +1396,7 @@ int cmd_fast_export(int argc,
1396
get_tags_and_duplicates(&revs.cmdline);
1397
1398
if (prepare_revision_walk(&revs))
1398
- die("revision walk setup failed");
1399
+ die(_("revision walk setup failed"));
1400
1401
revs.reverse = 1;
1402
revs.diffopt.format_callback = show_filemodify;