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

[PATCH] diff.c: use utf8_strwidth() instead of strlen() for display width

From
CGChandra Pratap via GitGitGadget <gitgitgadget@gmail.com>
Date
Feb 18, 2024, 18:37 UTC
Message-ID
<pull.1668.git.1708281443289.gitgitgadget@gmail.com>
From: Chandra Pratap <chandrapratap3519@gmail.com>
Signed-off-by: Chandra Pratap <chandrapratap3519@gmail.com>
---
    diff.c: use utf8_strwidth() instead of strlen() for display width
Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-1668%2FChand-ra%2Fdiff-v1
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-1668/Chand-ra/diff-v1
Pull-Request: https://github.com/gitgitgadget/git/pull/1668
 diff.c | 7 +------
 1 file changed, 1 insertion(+), 6 deletions(-)
diff --git a/diff.c b/diff.c
index ccfa1fca0d0..02d60af6749 100644
--- a/diff.c
+++ b/diff.c
@@ -2712,13 +2712,8 @@ static void show_stats(struct diffstat_t *data, struct diff_options *options)
 	 * making the line longer than the maximum width.
 	 */
 
-	/*
-	 * NEEDSWORK: line_prefix is often used for "log --graph" output
-	 * and contains ANSI-colored string.  utf8_strnwidth() should be
-	 * used to correctly count the display width instead of strlen().
-	 */
 	if (options->stat_width == -1)
-		width = term_columns() - strlen(line_prefix);
+		width = term_columns() - utf8_strwidth(line_prefix);
 	else
 		width = options->stat_width ? options->stat_width : 80;
 	number_width = decimal_width(max_change) > number_width ?

base-commit: 2996f11c1d11ab68823f0939b6469dedc2b9ab90
-- 
gitgitgadget
Next: Patrick Steinhardt
Message 1 of 3 in “diff.c: use utf8_strwidth() instead of strlen() for display width”
  1. diff.c: use utf8_strwidth() instead of strlen() for display widthChandra Pratap via GitGitGadget, Feb 18, 2024
  2. Patrick SteinhardtFeb 19, 2024
  3. Junio C HamanoFeb 19, 2024

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.