git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: Feature request: better error messages when UTF-8 bites

From
Torsten Bögershausen <tboegi@web.de>
Date
Jul 28, 2022, 18:01 UTC
Message-ID
<20220728180128.dlhhu7wlbubvnyph@tb-raspi4>
In-Reply-To
<1e454493-ca57-ca2e-7d82-7333a769817e@gmail.com>
[]
Show 8 quoted lines
>
> BTW you actually raise another issue - I do think for file paths git could
> either recompose (NFC) or decompose (NFD) the strings on storage and
> comparison (which should probably be an option... the current default for
> 2.30.2 is to treat them and print them as binary (escaped on print).
> Consider the following when using core.quotePath=false:
>
> $ touch "nfc_$(printf '\xf4')"

This is not valid unicode, isn't it ? Probably we need to use the octal version, since not all printf() implementation support hex values starting with 0x, but all of them support octal:

auml=$(printf '\303\244') aumlcdiar=$(printf '\141\314\210')

Show 8 quoted lines
> $ touch "nfd_$(printf '\x6f\xcc\x82')"
> $ git add nf[cd]*
> $ git status
> On branch test
> Changes to be committed:
>   (use "git restore --staged <file>..." to unstage)
>     new file:   nfc_ô
>     new file:   nfd_ô
>
> I'm not sure how the Unicode will be translated here, it might depend on the
> mail client if they even's get sent as-is, but both shows the exact same
> file name, one in NFD and one in NFC format.

Translated by "whom" ? Most programs do no translate anything here.

Show 5 quoted lines
>
> Both are canonically equivalent and reversible. It appears MacOS already
> decompose (NFD?) filenames by default and git provides an option to
> recompose the characters (core.precomposeUnicode) which, according to the
> manual, is not even usable on Linux...

Yes. Technically you can have both under Linux, at least unless you are running ZFS, which may be created unicode-aware (or not, that is the default).

But why do you want to have 2 files on disk with different normalizations ?
Show 5 quoted lines
>
> More on Unicode normalization: https://unicode.org/reports/tr15/
>
> --
> Thomas
Previous: Thomas Guyot
Message 4 of 4 in “Feature request: better error messages when UTF-8 bites”
  1. CHJul 27, 2022
  2. Johannes SixtJul 28, 2022
  3. Thomas GuyotJul 28, 2022
  4. Torsten BögershausenJul 28, 2022

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.