From: Junio C Hamano Date: Fri, 27 Feb 2026 18:04:57 GMT Subject: Re: [GSoC PATCH v2 0/2] diff: handle UTF-8 chars in prefix when calculating diffstat width Message-ID: In-Reply-To: LorenzoPegorari writes: > This patch aims to fix a bug where the calculation of the diffstat width > incorrectly uses the strlen() of line_prefix instead of its actual > display width. > > This patch addresses the NEEDSWORK item added by ce8529b2 (diff: leave > NEEDWORK notes in show_stats() function, 2022-10-21). > > V2 DIFF: > * Changed references from "ANSI char" to "UTF-8 char" Is that correct? I thought these references are mostly about the ANSI color escape sequences that are used to paint strings in color e.g., printf "This is shown in \033[31mRED\033[0m color\012" uses "\033[31m" (use RED as the foreground color) and "\033[0m" (reset all styles and colors). The problem the NEEDSWORK comment talks about is that the code uses strlen() but these two sequences in the above example are 0-width as far as the terminal display width computation is concerned. And that is why we want to use utf8_strnwidth() with SKIP_ANSI bit on. > diff.c | 12 ++++-------- > t/b | 0 > t/t4052-stat-output.sh | 30 ++++++++++++++++++++++++++++++ > 3 files changed, 34 insertions(+), 8 deletions(-) > create mode 100644 t/b I doubt you meant to add a new file there ;-)