Re: [PATCH v2 15/16] fsck: reduce word legos to help i18n
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Nov 6, 2018, 03:41 UTC
- Message-ID
- <xmqqbm72g9ee.fsf@gitster-ct.c.googlers.com>
- In-Reply-To
- <20181105192059.20303-16-pclouds@gmail.com>
Nguyễn Thái Ngọc Duy <pclouds@gmail.com> writes:
Show 8 quoted lines
> static const char *describe_object(struct object *obj)
> {
> - static struct strbuf buf = STRBUF_INIT;
> - char *name = name_objects ?
> - lookup_decoration(fsck_walk_options.object_names, obj) : NULL;
> + static struct strbuf bufs[4] = {
> + STRBUF_INIT, STRBUF_INIT, STRBUF_INIT, STRBUF_INIT
> + };If you need to repeat _INIT anyway, perhaps you want to actively omit the 4 from above, no? If you typed 6 by mistake instead, you'd be in trouble when using the last two elements.
Show 8 quoted lines
> static int objerror(struct object *obj, const char *err)
> {
> errors_found |= ERROR_OBJECT;
> - objreport(obj, "error", err);
> + fprintf_ln(stderr, "error in %s %s: %s",
> + printable_type(obj), describe_object(obj), err);
> return -1;
> }Makes sense.
Show 14 quoted lines
> static int fsck_error_func(struct fsck_options *o,
> struct object *obj, int type, const char *message)
> {
> - objreport(obj, (type == FSCK_WARN) ? "warning" : "error", message);
> - return (type == FSCK_WARN) ? 0 : 1;
> + if (type == FSCK_WARN) {
> + fprintf_ln(stderr, "warning in %s %s: %s",
> + printable_type(obj), describe_object(obj), message);
> + return 0;
> + }
> +
> + fprintf_ln(stderr, "error in %s %s: %s",
> + printable_type(obj), describe_object(obj), message);
> + return 1;Make it look more symmetrical like the original, perhaps by
if (type == FSCK_WARN) {
...
return 0;
} else { /* FSCK_ERROR */
...
return 1;
}Actually, wouldn't it be clearer to see what is going on, if we did it like this instead?
const char *fmt = (type == FSCK_WARN)
? N_("warning in %s %s: %s")
: N_("error in %s %s: %s");
fprintf_ln(stderr, _(fmt),
printable_type(obj), describe_object(obj), message);
return (type == FSCK_WARN) ? 0 : 1;It would show that in either case we show these three things in the message. I dunno.