]> git.ipfire.org Git - thirdparty/git.git/commit
doc: pretty-formats note wide char limitations, and add tests
authorPhilip Oakley <philipoakley@iee.email>
Thu, 19 Jan 2023 18:18:27 +0000 (18:18 +0000)
committerJunio C Hamano <gitster@pobox.com>
Thu, 19 Jan 2023 22:35:15 +0000 (14:35 -0800)
commit540e7bc477fc9bc491221075c0fade0722e63945
tree12ea96f39153a856bc301a7b764e1b05d63791e7
parentb5cd634d7a30074452c5aa3b0ce66ce794c4d565
doc: pretty-formats note wide char limitations, and add tests

The previous commits added clarifications to the column alignment
placeholders, note that the spaces are optional around the parameters.

Also, a proposed extension [1] to allow hard truncation (without
ellipsis '..') highlighted that the existing code does not play well
with wide characters, such as Asian fonts and emojis.

For example, N wide characters take 2N columns so won't fit an odd number
column width, causing misalignment somewhere.

Further analysis also showed that decomposed characters, e.g. separate
`a` + `umlaut` Unicode code-points may also be mis-counted, in some cases
leaving multiple loose `umlauts` all combined together.

Add some notes about these limitations, and add basic tests to demonstrate
them.

The chosen solution for the tests is to substitute any wide character
that overlaps a splitting boundary for the unicode vertical ellipsis
code point as a rare but 'obvious' substitution.

An alternative could be the substitution with a single dot '.' which
matches regular expression usage, and our two dot ellipsis, and further
in scenarios where the bulk of the text is wide characters, would be
obvious. In mainly 'ascii' scenarios a singleton emoji being substituted
by a dot could be confusing.

It is enough that the tests fail cleanly. The final choice for the
substitute character can be deferred.

[1]
https://lore.kernel.org/git/20221030185614.3842-1-philipoakley@iee.email/

Signed-off-by: Philip Oakley <philipoakley@iee.email>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Documentation/pretty-formats.txt
t/t4205-log-pretty-formats.sh