rerere: mark strings for translation
'git rerere' is considered a porcelain command and as such its output should be translated. Its functionality is also only enabled through a config setting, so scripts really shouldn't rely on the output either way. Signed-off-by: Thomas Gummerer <t.gummerer@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Thomas Gummerer committed
Aug 5, 2018 at 18:20 UTC
2373b6505966244ab3f5b630680169692d28f6f6
2 files changed
+36
-36
builtin/rerere.c
+2
-2
@@ -75,7 +75,7 @@ int cmd_rerere(int argc, const char **argv, const char *prefix)
75
if (!strcmp(argv[0], "forget")) {
76
struct pathspec pathspec;
77
if (argc < 2)
78
- warning("'git rerere forget' without paths is deprecated");
78
+ warning(_("'git rerere forget' without paths is deprecated"));
79
parse_pathspec(&pathspec, 0, PATHSPEC_PREFER_CWD,
80
prefix, argv + 1);
81
return rerere_forget(&pathspec);
@@ -107,7 +107,7 @@ int cmd_rerere(int argc, const char **argv, const char *prefix)
107
const char *path = merge_rr.items[i].string;
108
const struct rerere_id *id = merge_rr.items[i].util;
109
if (diff_two(rerere_path(id, "preimage"), path, path, path))
110
- die("unable to generate diff for '%s'", rerere_path(id, NULL));
110
+ die(_("unable to generate diff for '%s'"), rerere_path(id, NULL));
111
}
112
} else
113
usage_with_options(rerere_usage, options);
rerere.c
+34
-34
@@ -212,7 +212,7 @@ static void read_rr(struct string_list *rr)
212
213
/* There has to be the hash, tab, path and then NUL */
214
if (buf.len < 42 || get_sha1_hex(buf.buf, sha1))
215
- die("corrupt MERGE_RR");
215
+ die(_("corrupt MERGE_RR"));
216
217
if (buf.buf[40] != '.') {
218
variant = 0;
@@ -221,10 +221,10 @@ static void read_rr(struct string_list *rr)
221
errno = 0;
222
variant = strtol(buf.buf + 41, &path, 10);
223
if (errno)
224
- die("corrupt MERGE_RR");
224
+ die(_("corrupt MERGE_RR"));
225
}
226
if (*(path++) != '\t')
227
- die("corrupt MERGE_RR");
227
+ die(_("corrupt MERGE_RR"));
228
buf.buf[40] = '\0';
229
id = new_rerere_id_hex(buf.buf);
230
id->variant = variant;
@@ -259,12 +259,12 @@ static int write_rr(struct string_list *rr, int out_fd)
259
rr->items[i].string, 0);
260
261
if (write_in_full(out_fd, buf.buf, buf.len) < 0)
262
- die("unable to write rerere record");
262
+ die(_("unable to write rerere record"));
263
264
strbuf_release(&buf);
265
}
266
if (commit_lock_file(&write_lock) != 0)
267
- die("unable to write rerere record");
267
+ die(_("unable to write rerere record"));
268
return 0;
269
}
270
@@ -484,12 +484,12 @@ static int handle_file(const char *path, unsigned char *sha1, const char *output
484
io.input = fopen(path, "r");
485
io.io.wrerror = 0;
486
if (!io.input)
487
- return error_errno("could not open '%s'", path);
487
+ return error_errno(_("could not open '%s'"), path);
488
489
if (output) {
490
io.io.output = fopen(output, "w");
491
if (!io.io.output) {
492
- error_errno("could not write '%s'", output);
492
+ error_errno(_("could not write '%s'"), output);
493
fclose(io.input);
494
return -1;
495
}
@@ -499,15 +499,15 @@ static int handle_file(const char *path, unsigned char *sha1, const char *output
499
500
fclose(io.input);
501
if (io.io.wrerror)
502
- error("there were errors while writing '%s' (%s)",
502
+ error(_("there were errors while writing '%s' (%s)"),
503
path, strerror(io.io.wrerror));
504
if (io.io.output && fclose(io.io.output))
505
- io.io.wrerror = error_errno("failed to flush '%s'", path);
505
+ io.io.wrerror = error_errno(_("failed to flush '%s'"), path);
506
507
if (hunk_no < 0) {
508
if (output)
509
unlink_or_warn(output);
510
- return error("could not parse conflict hunks in '%s'", path);
510
+ return error(_("could not parse conflict hunks in '%s'"), path);
511
}
512
if (io.io.wrerror)
513
return -1;
@@ -568,7 +568,7 @@ static int find_conflict(struct string_list *conflict)
568
{
569
int i;
570
if (read_cache() < 0)
571
- return error("index file corrupt");
571
+ return error(_("index file corrupt"));
572
573
for (i = 0; i < active_nr;) {
574
int conflict_type;
@@ -601,7 +601,7 @@ int rerere_remaining(struct string_list *merge_rr)
601
if (setup_rerere(merge_rr, RERERE_READONLY))
602
return 0;
603
if (read_cache() < 0)
604
- return error("index file corrupt");
604
+ return error(_("index file corrupt"));
605
606
for (i = 0; i < active_nr;) {
607
int conflict_type;
@@ -684,17 +684,17 @@ static int merge(const struct rerere_id *id, const char *path)
684
* Mark that "postimage" was used to help gc.
685
*/
686
if (utime(rerere_path(id, "postimage"), NULL) < 0)
687
- warning_errno("failed utime() on '%s'",
687
+ warning_errno(_("failed utime() on '%s'"),
688
rerere_path(id, "postimage"));
689
690
/* Update "path" with the resolution */
691
f = fopen(path, "w");
692
if (!f)
693
- return error_errno("could not open '%s'", path);
693
+ return error_errno(_("could not open '%s'"), path);
694
if (fwrite(result.ptr, result.size, 1, f) != 1)
695
- error_errno("could not write '%s'", path);
695
+ error_errno(_("could not write '%s'"), path);
696
if (fclose(f))
697
- return error_errno("writing '%s' failed", path);
697
+ return error_errno(_("writing '%s' failed"), path);
698
699
out:
700
free(cur.ptr);
@@ -714,13 +714,13 @@ static void update_paths(struct string_list *update)
714
struct string_list_item *item = &update->items[i];
715
if (add_file_to_cache(item->string, 0))
716
exit(128);
717
- fprintf(stderr, "Staged '%s' using previous resolution.\n",
717
+ fprintf_ln(stderr, _("Staged '%s' using previous resolution."),
718
item->string);
719
}
720
721
if (write_locked_index(&the_index, &index_lock,
722
COMMIT_LOCK | SKIP_IF_UNCHANGED))
723
- die("unable to write new index file");
723
+ die(_("unable to write new index file"));
724
}
725
726
static void remove_variant(struct rerere_id *id)
@@ -752,7 +752,7 @@ static void do_rerere_one_path(struct string_list_item *rr_item,
752
if (!handle_file(path, NULL, NULL)) {
753
copy_file(rerere_path(id, "postimage"), path, 0666);
754
id->collection->status[variant] |= RR_HAS_POSTIMAGE;
755
- fprintf(stderr, "Recorded resolution for '%s'.\n", path);
755
+ fprintf_ln(stderr, _("Recorded resolution for '%s'."), path);
756
free_rerere_id(rr_item);
757
rr_item->util = NULL;
758
return;
@@ -786,9 +786,9 @@ static void do_rerere_one_path(struct string_list_item *rr_item,
786
if (rerere_autoupdate)
787
string_list_insert(update, path);
788
else
789
- fprintf(stderr,
790
- "Resolved '%s' using previous resolution.\n",
791
- path);
789
+ fprintf_ln(stderr,
790
+ _("Resolved '%s' using previous resolution."),
791
+ path);
792
free_rerere_id(rr_item);
793
rr_item->util = NULL;
794
return;
@@ -802,11 +802,11 @@ static void do_rerere_one_path(struct string_list_item *rr_item,
802
if (id->collection->status[variant] & RR_HAS_POSTIMAGE) {
803
const char *path = rerere_path(id, "postimage");
804
if (unlink(path))
805
- die_errno("cannot unlink stray '%s'", path);
805
+ die_errno(_("cannot unlink stray '%s'"), path);
806
id->collection->status[variant] &= ~RR_HAS_POSTIMAGE;
807
}
808
id->collection->status[variant] |= RR_HAS_PREIMAGE;
809
- fprintf(stderr, "Recorded preimage for '%s'\n", path);
809
+ fprintf_ln(stderr, _("Recorded preimage for '%s'"), path);
810
}
811
812
static int do_plain_rerere(struct string_list *rr, int fd)
@@ -878,7 +878,7 @@ static int is_rerere_enabled(void)
878
return rr_cache_exists;
879
880
if (!rr_cache_exists && mkdir_in_gitdir(git_path_rr_cache()))
881
- die("could not create directory '%s'", git_path_rr_cache());
881
+ die(_("could not create directory '%s'"), git_path_rr_cache());
882
return 1;
883
}
884
@@ -1031,7 +1031,7 @@ static int rerere_forget_one_path(const char *path, struct string_list *rr)
1031
*/
1032
ret = handle_cache(path, sha1, NULL);
1033
if (ret < 1)
1034
- return error("could not parse conflict hunks in '%s'", path);
1034
+ return error(_("could not parse conflict hunks in '%s'"), path);
1035
1036
/* Nuke the recorded resolution for the conflict */
1037
id = new_rerere_id(sha1);
@@ -1049,7 +1049,7 @@ static int rerere_forget_one_path(const char *path, struct string_list *rr)
1049
handle_cache(path, sha1, rerere_path(id, "thisimage"));
1050
if (read_mmfile(&cur, rerere_path(id, "thisimage"))) {
1051
free(cur.ptr);
1052
- error("failed to update conflicted state in '%s'", path);
1052
+ error(_("failed to update conflicted state in '%s'"), path);
1053
goto fail_exit;
1054
}
1055
cleanly_resolved = !try_merge(id, path, &cur, &result);
@@ -1060,16 +1060,16 @@ static int rerere_forget_one_path(const char *path, struct string_list *rr)
1060
}
1061
1062
if (id->collection->status_nr <= id->variant) {
1063
- error("no remembered resolution for '%s'", path);
1063
+ error(_("no remembered resolution for '%s'"), path);
1064
goto fail_exit;
1065
}
1066
1067
filename = rerere_path(id, "postimage");
1068
if (unlink(filename)) {
1069
if (errno == ENOENT)
1070
- error("no remembered resolution for '%s'", path);
1070
+ error(_("no remembered resolution for '%s'"), path);
1071
else
1072
- error_errno("cannot unlink '%s'", filename);
1072
+ error_errno(_("cannot unlink '%s'"), filename);
1073
goto fail_exit;
1074
}
1075
@@ -1079,7 +1079,7 @@ static int rerere_forget_one_path(const char *path, struct string_list *rr)
1079
* the postimage.
1080
*/
1081
handle_cache(path, sha1, rerere_path(id, "preimage"));
1082
- fprintf(stderr, "Updated preimage for '%s'\n", path);
1082
+ fprintf_ln(stderr, _("Updated preimage for '%s'"), path);
1083
1084
/*
1085
* And remember that we can record resolution for this
@@ -1088,7 +1088,7 @@ static int rerere_forget_one_path(const char *path, struct string_list *rr)
1088
item = string_list_insert(rr, path);
1089
free_rerere_id(item);
1090
item->util = id;
1091
- fprintf(stderr, "Forgot resolution for '%s'\n", path);
1091
+ fprintf(stderr, _("Forgot resolution for '%s'\n"), path);
1092
return 0;
1093
1094
fail_exit:
@@ -1103,7 +1103,7 @@ int rerere_forget(struct pathspec *pathspec)
1103
struct string_list merge_rr = STRING_LIST_INIT_DUP;
1104
1105
if (read_cache() < 0)
1106
- return error("index file corrupt");
1106
+ return error(_("index file corrupt"));
1107
1108
fd = setup_rerere(&merge_rr, RERERE_NOAUTOUPDATE);
1109
if (fd < 0)
@@ -1191,7 +1191,7 @@ void rerere_gc(struct string_list *rr)
1191
git_config(git_default_config, NULL);
1192
dir = opendir(git_path("rr-cache"));
1193
if (!dir)
1194
- die_errno("unable to open rr-cache directory");
1194
+ die_errno(_("unable to open rr-cache directory"));
1195
/* Collect stale conflict IDs ... */
1196
while ((e = readdir(dir))) {
1197
struct rerere_dir *rr_dir;