]> Kevux Git Server - rit/commit
diff: handle ANSI escape codes in prefix when calculating diffstat width
authorLorenzoPegorari <lorenzo.pegorari2002@gmail.com>
Fri, 27 Feb 2026 21:45:19 +0000 (22:45 +0100)
committerJunio C Hamano <gitster@pobox.com>
Fri, 27 Feb 2026 21:59:22 +0000 (13:59 -0800)
commit1a9df8de368cbebd881336f64e424422f3dbb993
tree612cbc791abde72fe318c8c3f84cb1a5b9256582
parent9a2fb147f2c61d0cab52c883e7e26f5b7948e3ed
diff: handle ANSI escape codes in prefix when calculating diffstat width

The diffstat width is calculated by taking the terminal width and
incorrectly subtracting the `strlen()` of `line_prefix`, instead of the
actual display width of `line_prefix`, which may contain ANSI escape
codes (e.g., ANSI-colored strings in `log --graph --stat`).

Utilize the display width instead, obtained via `utf8_strnwidth()` with
the flag `skip_ansi`.

Signed-off-by: LorenzoPegorari <lorenzo.pegorari2002@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
diff.c