[PATCH 0/2] Fix misaligned output of git repo structure
- From
Jiang Xin <worldhello.net@gmail.com>
- Date
- Nov 14, 2025, 05:52 UTC
- Message-ID
- <cover.1763098804.git.worldhello.net@gmail.com>
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