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

Re: [PATCH 1/1] Fix --stat width calculations to handle --graph

From
Junio C Hamano <gitster@pobox.com>
Date
Mar 20, 2012, 17:23 UTC
Message-ID
<7vaa3b6v9z.fsf@alter.siamese.dyndns.org>
In-Reply-To
<alpine.DEB.1.00.1203201109370.3340@s15462909.onlinehome-server.info>
Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:
Show 14 quoted lines
> However, a little nit, since this list is so famous for "just a little
> nit": I'd prefer to factor-out the indent width measuring, like so:
>
> static int count_pipes_and_spaces(const char *string)
> {
> 	int count;
>
> 	for (count = 0; *string; string++)
> 		if (*string == '|' || *string == ' ')
> 			count++;
>
> 	return count;
> }
>

I agree that this is much better than the original by Lucian, but if we were to go this route, I would prefer to see it *not* count pipes and spaces, but actually measure the display width of the string. Both the name of the function and the implementation would have to change, of course.

Even though I didn't look very closely, I do not think it should be too hard for graph.c to tell the diff_options structure how wide a prefix it placed in the output_prefix, so use of such a "display_columns()" function would be wasteful for this particular case, but for a more general case, it would come in handy as a helper function, and at that point, this should not hide in diff.c as a static function.

Thanks.
Previous: Johannes SchindelinNext: Lucian Poston
Message 4 of 7 in “Adjust diff stat width calculations so lines do not wrap in terminal when using --graph”
  1. 0/1 Adjust diff stat width calculations so lines do not wrap in terminal when using --graphLucian Poston, Mar 20, 2012
  2. 1/1 Fix --stat width calculations to handle --graphLucian Poston, Mar 20, 2012
  3. Johannes SchindelinMar 20, 2012
  4. Junio C HamanoMar 20, 2012
  5. Lucian PostonMar 22, 2012
  6. Junio C HamanoMar 20, 2012
  7. Lucian PostonMar 22, 2012

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.