fsck: reduce word legos to help i18n
These messages will be marked for translation later. Reduce word legos and give translators almost full phrases. describe_object() is updated so that it can be called from printf() twice. While at there, remove \n from the strings to reduce a bit of work from translators. 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
Nov 10, 2018 at 06:16 UTC
bbb15c5193868a28f4eab4e1878af0f343e7d7c9
1 file changed
+40
-25
builtin/fsck.c
+40
-25
@@ -52,16 +52,24 @@ static int name_objects;
52
53
static const char *describe_object(struct object *obj)
54
{
55
- static struct strbuf buf = STRBUF_INIT;
56
- char *name = name_objects ?
57
- lookup_decoration(fsck_walk_options.object_names, obj) : NULL;
55
+ static struct strbuf bufs[] = {
56
+ STRBUF_INIT, STRBUF_INIT, STRBUF_INIT, STRBUF_INIT
57
+ };
58
+ static int b = 0;
59
+ struct strbuf *buf;
60
+ char *name = NULL;
61
59
- strbuf_reset(&buf);
60
- strbuf_addstr(&buf, oid_to_hex(&obj->oid));
62
+ if (name_objects)
63
+ name = lookup_decoration(fsck_walk_options.object_names, obj);
64
+
65
+ buf = bufs + b;
66
+ b = (b + 1) % ARRAY_SIZE(bufs);
67
+ strbuf_reset(buf);
68
+ strbuf_addstr(buf, oid_to_hex(&obj->oid));
69
if (name)
62
- strbuf_addf(&buf, " (%s)", name);
70
+ strbuf_addf(buf, " (%s)", name);
71
64
- return buf.buf;
72
+ return buf->buf;
73
}
74
75
static const char *printable_type(struct object *obj)
@@ -105,25 +113,29 @@ static int fsck_config(const char *var, const char *value, void *cb)
113
return git_default_config(var, value, cb);
114
}
115
108
-static void objreport(struct object *obj, const char *msg_type,
109
- const char *err)
110
-{
111
- fprintf(stderr, "%s in %s %s: %s\n",
112
- msg_type, printable_type(obj), describe_object(obj), err);
113
-}
114
-
116
static int objerror(struct object *obj, const char *err)
117
{
118
errors_found |= ERROR_OBJECT;
118
- objreport(obj, "error", err);
119
+ fprintf_ln(stderr, "error in %s %s: %s",
120
+ printable_type(obj), describe_object(obj), err);
121
return -1;
122
}
123
124
static int fsck_error_func(struct fsck_options *o,
125
struct object *obj, int type, const char *message)
126
{
125
- objreport(obj, (type == FSCK_WARN) ? "warning" : "error", message);
126
- return (type == FSCK_WARN) ? 0 : 1;
127
+ switch (type) {
128
+ case FSCK_WARN:
129
+ fprintf_ln(stderr, "warning in %s %s: %s",
130
+ printable_type(obj), describe_object(obj), message);
131
+ return 0;
132
+ case FSCK_ERROR:
133
+ fprintf_ln(stderr, "error in %s %s: %s",
134
+ printable_type(obj), describe_object(obj), message);
135
+ return 1;
136
+ default:
137
+ BUG("%d (FSCK_IGNORE?) should never trigger this callback", type);
138
+ }
139
}
140
141
static struct object_array pending;
@@ -165,10 +177,12 @@ static int mark_object(struct object *obj, int type, void *data, struct fsck_opt
177
178
if (!(obj->flags & HAS_OBJ)) {
179
if (parent && !has_object_file(&obj->oid)) {
168
- printf("broken link from %7s %s\n",
169
- printable_type(parent), describe_object(parent));
170
- printf(" to %7s %s\n",
171
- printable_type(obj), describe_object(obj));
180
+ printf_ln("broken link from %7s %s\n"
181
+ " to %7s %s",
182
+ printable_type(parent),
183
+ describe_object(parent),
184
+ printable_type(obj),
185
+ describe_object(obj));
186
errors_found |= ERROR_REACHABLE;
187
}
188
return 1;
@@ -371,10 +385,11 @@ static int fsck_obj(struct object *obj, void *buffer, unsigned long size)
385
struct tag *tag = (struct tag *) obj;
386
387
if (show_tags && tag->tagged) {
374
- printf("tagged %s %s", printable_type(tag->tagged),
375
- describe_object(tag->tagged));
376
- printf(" (%s) in %s\n", tag->tag,
377
- describe_object(&tag->object));
388
+ printf_ln("tagged %s %s (%s) in %s",
389
+ printable_type(tag->tagged),
390
+ describe_object(tag->tagged),
391
+ tag->tag,
392
+ describe_object(&tag->object));
393
}
394
}
395