summaryrefslogtreecommitdiffstats
path: root/contrib/persistent-https
diff options
context:
space:
mode:
authorLorenzoPegorari <lorenzo.pegorari2002@gmail.com>2026-01-16 01:05:03 +0100
committerJunio C Hamano <gitster@pobox.com>2026-01-16 08:24:35 -0800
commitf85b49f3d4af5ee0b428285799ac711d6abe1cfb (patch)
tree6fbe8af03a0320a22cd4fbd00ad9647bca69a234 /contrib/persistent-https
parent9a2fb147f2c61d0cab52c883e7e26f5b7948e3ed (diff)
downloadgit-f85b49f3d4af5ee0b428285799ac711d6abe1cfb.tar.gz
git-f85b49f3d4af5ee0b428285799ac711d6abe1cfb.zip
diff: improve scaling of filenames in diffstat to handle UTF-8 chars
The `show_stats()` function tries to scale the filenames in the diffstat to ensure they don't exceed the given `name-width`. It does so by calculating the "display width" of the characters to be dropped, but then advances the filename pointer by that number of bytes. However, the "display width" of a character is not always equal to its byte count. The result is that sometimes, when displaying UTF-8 characters, filenames exceed the given `name-width`, and frequently the bytes of the UTF-8 characters are truncated. The following is an example of the issue, where the 2 files are "HelloHi" and "Hello你好", and `name-width=6`: ...oHi | 0 ...<BD><A0>好 | 0 Make the filename pointer move by the actual number of bytes of the characters to drop from the filename, rather than their display width, using the `utf8_width()` function. Force `len` to not be less than 0 (this happens if the given `name-width` is 2 or less), otherwise an infinite loop is entered. Signed-off-by: LorenzoPegorari <lorenzo.pegorari2002@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'contrib/persistent-https')
0 files changed, 0 insertions, 0 deletions