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

Re: [GSoC PATCH v2 2/2] t4052: add test for diffstat width when prefix contains UTF-8 chars

From
Junio C Hamano <gitster@pobox.com>
Date
Feb 27, 2026, 18:08 UTC
Message-ID
<xmqq1pi6rrdk.fsf@gitster.g>
In-Reply-To
<984fa10d728aad049d0430472e85f1ed0e5ea4de.1772136203.git.lorenzo.pegorari2002@gmail.com>
LorenzoPegorari <lorenzo.pegorari2002@gmail.com> writes:
> Add test checking the calculation of the diffstat display width when the
> `line_prefix`, which is text that goes before the diffstat, contains
> UTF-8 characters.

This does not want to say UTF-8 for two reasons. US-ASCII is a subset of UTF-8, and more importantly, most of the problems miscounting the display width of the line-prefix part comes from the fact that ANSI color escapes are 0-width but consumes strlen() bytes.

Curiously ...
Show 5 quoted lines
> +# git-log will print only 1 commit containing a single branch graph and a diffstat.
> +# The diffstat will be only one file, with a placeholder FILENAME, that, with
> +# enough terminal display width, will contain the following line:
> +#     "<RED>|<RESET>  ${FILENAME} | 0"
> +# where "<RED>" and "<RESET>" are ANSI escape codes to color the text.

... this does say "ANSI escape codes to color the text", which is exactly what we want to say ;-)

Previous: LorenzoPegorariNext: Junio C Hamano
Message 10 of 14 in “diff: handle ANSI chars in prefix when calculating diffstat width”
  1. 0/2 diff: handle ANSI chars in prefix when calculating diffstat widthLorenzoPegorari, Feb 24, 2026
  2. 1/2 diff: handle ANSI chars in prefix when calculating diffstat widthLorenzoPegorari, Feb 24, 2026
  3. 2/2 t4074: add test for diffstat width when prefix contains ANSI charsLorenzoPegorari, Feb 24, 2026
  4. Junio C HamanoFeb 24, 2026
  5. Lorenzo PegorariFeb 25, 2026
  6. Junio C HamanoFeb 24, 2026
  7. 0/2 diff: handle UTF-8 chars in prefix when calculating diffstat widthLorenzoPegorari, Feb 27, 2026
  8. 1/2 diff: handle UTF-8 chars in prefix when calculating diffstat widthLorenzoPegorari, Feb 27, 2026
  9. 2/2 t4052: add test for diffstat width when prefix contains UTF-8 charsLorenzoPegorari, Feb 27, 2026
  10. Junio C HamanoFeb 27, 2026
  11. Junio C HamanoFeb 27, 2026
  12. 0/2 diff: handle ANSI escape codes in prefix when calculating diffstat widthLorenzoPegorari, Feb 27, 2026
  13. 1/2 diff: handle ANSI escape codes in prefix when calculating diffstat widthLorenzoPegorari, Feb 27, 2026
  14. 2/2 t4052: test for diffstat width when prefix contains ANSI escape codesLorenzoPegorari, Feb 27, 2026

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.