All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jiang Xin <worldhello.net@gmail.com>
To: Junio C Hamano <gitster@pobox.com>,
	Git List <git@vger.kernel.org>,
	Justin Tobler <jltobler@gmail.com>
Cc: "Jiang Xin" <worldhello.net@gmail.com>,
	"Alexander Shopov" <ash@kambanaria.org>,
	"Mikel Forcada" <mikel.forcada@gmail.com>,
	"Ralf Thielow" <ralf.thielow@gmail.com>,
	"Jean-Noël Avila" <jn.avila@free.fr>,
	"Bagas Sanjaya" <bagasdotme@gmail.com>,
	"Dimitriy Ryazantcev" <DJm00n@mail.ru>,
	"Peter Krefting" <peter@softwolves.pp.se>,
	"Emir SARI" <bitigchi@me.com>, "Arkadii Yakovets" <ark@cho.red>,
	"Vũ Tiến Hưng" <newcomerminecraft@gmail.com>,
	"Teng Long" <dyroneteng@gmail.com>,
	"Yi-Jyun Pan" <pan93412@gmail.com>
Subject: [PATCH 0/2] Fix misaligned output of git repo structure
Date: Fri, 14 Nov 2025 00:52:43 -0500	[thread overview]
Message-ID: <cover.1763098804.git.worldhello.net@gmail.com> (raw)

While localizing Git 2.52.0, I noticed that the output table from git
repo structure becomes misaligned when displaying UTF-8 characters. For
example:

    | 仓库结构   | 值  |
    | -------------- | ---- |
    | * 引用       |      |
    |   * 计数     |   67 |
    |     * 分支   |    6 |
    |     * 标签   |   30 |
    |     * 远程   |   19 |
    |     * 其它   |   12 |
    |                |      |
    | * 可达对象 |      |
    |   * 计数     | 2217 |
    |     * 提交   |  279 |
    |     * 树      |  740 |
    |     * 数据对象 | 1168 |
    |     * 标签   |   30 |

The previous implementation used simple width formatting with printf()
which didn't properly handle multi-byte UTF-8 characters, causing
misaligned table columns when displaying repository structure
information.

This change modifies the stats_table_print_structure function to use
strbuf_utf8_align() instead of basic printf width specifiers. This
ensures proper column alignment regardless of the character encoding of
the content being displayed.

BTW, I used two AI coding tools (Claude Code and Gemini-CLI) to generate
the commits, and added the "Co-developed-by" trailers in the commit
messages by using one of my opensource project:

 - https://github.com/ai-coding-workshop/commit-msg


## Changes

Jiang Xin (2):
  t/unit-tests: add UTF-8 width tests for CJK chars
  builtin/repo: fix table alignment for UTF-8 characters

 Makefile                    |  1 +
 builtin/repo.c              | 22 ++++++++--
 t/meson.build               |  1 +
 t/unit-tests/u-utf8-width.c | 85 +++++++++++++++++++++++++++++++++++++
 4 files changed, 105 insertions(+), 4 deletions(-)
 create mode 100644 t/unit-tests/u-utf8-width.c

-- 
2.52.0.rc2.5.g4c20a63325.dirty


             reply	other threads:[~2025-11-14  5:52 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-11-14  5:52 Jiang Xin [this message]
2025-11-14  5:52 ` [PATCH 1/2] t/unit-tests: add UTF-8 width tests for CJK chars Jiang Xin
2025-11-14 20:17   ` Junio C Hamano
2025-11-15 12:38     ` Jiang Xin
2025-11-14  5:52 ` [PATCH 2/2] builtin/repo: fix table alignment for UTF-8 characters Jiang Xin
2025-11-14 17:50   ` Justin Tobler
2025-11-15 12:41     ` Jiang Xin
2025-11-14 20:00   ` Junio C Hamano
2025-11-15 12:54     ` Jiang Xin
2025-11-15 16:36       ` Junio C Hamano
2025-11-16 13:32         ` Jiang Xin
2025-11-16 16:51           ` Junio C Hamano
2025-11-14  7:41 ` [PATCH 0/2] Fix misaligned output of git repo structure Kristoffer Haugsbakk
2025-11-14  9:52   ` Jiang Xin
2025-11-14 19:22     ` Junio C Hamano
2025-11-15 12:25       ` Jiang Xin
2025-11-14 16:13 ` Junio C Hamano
2025-11-15 13:36 ` [PATCH v2 " Jiang Xin
2025-11-15 13:36   ` [PATCH v2 1/2] t/unit-tests: add UTF-8 width tests for CJK chars Jiang Xin
2025-11-15 13:36   ` [PATCH v2 2/2] builtin/repo: fix table alignment for UTF-8 characters Jiang Xin
2025-11-15 15:04     ` Phillip Wood
2025-11-15 16:49       ` Junio C Hamano

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=cover.1763098804.git.worldhello.net@gmail.com \
    --to=worldhello.net@gmail.com \
    --cc=DJm00n@mail.ru \
    --cc=ark@cho.red \
    --cc=ash@kambanaria.org \
    --cc=bagasdotme@gmail.com \
    --cc=bitigchi@me.com \
    --cc=dyroneteng@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=jltobler@gmail.com \
    --cc=jn.avila@free.fr \
    --cc=mikel.forcada@gmail.com \
    --cc=newcomerminecraft@gmail.com \
    --cc=pan93412@gmail.com \
    --cc=peter@softwolves.pp.se \
    --cc=ralf.thielow@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.