Re: [PATCH v2 15/16] fsck: reduce word legos to help i18n
- From
Duy Nguyen <pclouds@gmail.com>
- Date
- Nov 10, 2018, 04:59 UTC
- Message-ID
- <CACsJy8CT43QQRvkHefXnPtYHbAFQVB847bTYyj8Hxyt-csDkBA@mail.gmail.com>
- In-Reply-To
- <xmqqbm72g9ee.fsf@gitster-ct.c.googlers.com>
On Tue, Nov 6, 2018 at 4:41 AM Junio C Hamano <gitster@pobox.com> wrote:
Show 37 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.Specifying "type == FSCK_WARN" twice triggers me (what if we add a third fsck type?) so I just turn this to a switch/case block instead (and get to know the third fsck type FSCK_IGNORE).
-- Duy