branch -v: align even when branch names are in UTF-8
commit1452bd64f14efd888fe9c732f603173ba7fa595e
authorNguyễn Thái Ngọc Duy <pclouds@gmail.com>
Sat, 25 Aug 2012 18:17:12 +0000 (26 01:17 +0700)
committerJunio C Hamano <gitster@pobox.com>
Mon, 27 Aug 2012 18:42:28 +0000 (27 11:42 -0700)
tree4d9e48433340d151ee32802fdd52ab634adf9b87
parentb52183179bb0a97ea4d91d1248aca303d8e8f892
branch -v: align even when branch names are in UTF-8

Branch names are usually in ASCII so they are not the problem. The
problem most likely comes from "(no branch)" translation, which is
in UTF-8 and makes display-width calculation just wrong.  Clarify
this by renaming the field "len" in struct ref_item to "width", as
it stores the display-width and is used to compute the width of the
screen needed to show the names of all the branches, and compute the
display width using utf8_strwidth(), not byte-length with strlen().

Update document to mention the fact that we may want ref names in
UTF-8. Encodings that produce invalid UTF-8 are safe as utf8_strwidth()
falls back to strlen(). The ones that incidentally produce valid UTF-8
sequences will cause misalignment.

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Documentation/revisions.txt
builtin/branch.c