Re: git: problematic git status output with some translations (such as fr_FR)
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Mar 12, 2014, 18:53 UTC
- Message-ID
- <xmqqa9cvmeod.fsf@gitster.dls.corp.google.com>
- In-Reply-To
- <20131219194319.GB20443@google.com>
Jonathan Nieder <jrnieder@gmail.com> writes:
Show 12 quoted lines
> @@ -292,6 +291,48 @@ static const char *wt_status_diff_status_string(int status)
> }
> }
>
> +static int maxwidth(const char *(*label)(int), int minval, int maxval)
> +{
> + const char *s;
> + int result = 0, i;
> +
> + for (i = minval; i <= maxval; i++) {
> + const char *s = label(i);
> + int len = s ? strlen(s) : 0;Shouldn't this be a utf8_strwidth(), as the value is to count number of display columns to be used by the leading label part?
Show 29 quoted lines
> + if (len > result)
> + result = len;
> + }
> + return result;
> +}
> +
> +static void wt_status_print_unmerged_data(struct wt_status *s,
> + struct string_list_item *it)
> +{
> + const char *c = color(WT_STATUS_UNMERGED, s);
> + struct wt_status_change_data *d = it->util;
> + struct strbuf onebuf = STRBUF_INIT;
> + static char *padding;
> + const char *one, *how;
> + int len;
> +
> + if (!padding) {
> + int width = maxwidth(wt_status_unmerged_status_string, 1, 7);
> + width += strlen(" ");
> + padding = xmallocz(width);
> + memset(padding, ' ', width);
> + }
> +
> + one = quote_path(it->string, s->prefix, &onebuf);
> + status_printf(s, color(WT_STATUS_HEADER, s), "\t");
> +
> + how = wt_status_unmerged_status_string(d->stagemask);
> + if (!how)
> + how = _("bug");I'd rather see the callee do this _("bug") thing, not this particular caller.
> + len = strlen(padding) - utf8_strwidth(how); > + status_printf_more(s, c, "%s%.*s%s\n", how, len, padding, one); > + strbuf_release(&onebuf); > +}