git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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);
> +}
Previous: Duy NguyenNext: Junio C Hamano
Message 7 of 12 in “Re: git: problematic git status output with some translations (such as fr_FR)”
  1. Jonathan NiederDec 19, 2013
  2. Junio C HamanoDec 19, 2013
  3. Jonathan NiederDec 19, 2013
  4. Duy NguyenDec 19, 2013
  5. Raphael HertzogJan 16, 2014
  6. Duy NguyenFeb 8, 2014
  7. Junio C HamanoMar 12, 2014
  8. wt-status: i18n of section labelsJunio C Hamano, Mar 12, 2014
  9. Sandy CarterMar 12, 2014
  10. Junio C HamanoMar 12, 2014
  11. Sandy CarterMar 12, 2014
  12. Junio C HamanoMar 13, 2014

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.