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

[BUG] 'ls-files path' fails if absolute path of workdir contains NFD (macOS)

From
JTJun T <takimoto-j@kba.biglobe.ne.jp>
Date
Apr 30, 2024, 03:27 UTC
Message-ID
<55D75808-70E0-46FA-906D-C00CD612A262@kba.biglobe.ne.jp>

On macOS, 'git ls-files path' does not work (gives an error) if the absolute 'path' contains characters in NFD (decomposed). I guess this is a (minor) bug of git.

[1] How to reproduce the problem

On macOS, git 2.39.3 or 2.45.0.219.gb9fe23f5ca(next branch), file system can be APFS or HFS.

with zsh or bash: % cd /somewhere # some safe place, /tmp or ~/tmp etc. % mkdir $'u\xcc\x88' # ü in NFD % cd ü # or cd $'u\xcc\x88' or cd $'\xc3\xbc' % git init % git ls-files $'/somewhere/u\xcc\x88' # NFD fatal: /somewhere/ü: '/somewhere/ü' is outside repository at '/somewhere/ü' % git ls-files $'/somewhere/\xc3\xbc' # NFC (the same error as above)

In the 'fatal:' error message, there are three ü; the 1st and 2nd are in NFC, the 3rd is in NFD.

[2] Some analysis

The path on the command line $'/somewhere/u\xcc\x88' is converted to NFC by precompose_argv_prefix(), called at git.c:451 in run_builtin().

But get_git_work_tree() (called at setup.c:50, in abspath_part_inside_repo()) returns the work_tree in NFD, and comparing it with the path in NFC (setup.c:92) fails.

I'm not familiar with git internals, but maybe get_git_work_tree() should return NFC (on macoS)?

-- Jun (Jun-ichi Takimoto)

Next: Torsten Bögershausen
Message 1 of 4 in “[BUG] 'ls-files path' fails if absolute path of workdir contains NFD (macOS)”
  1. Jun TApr 30, 2024
  2. Torsten BögershausenApr 30, 2024
  3. Jun. TApr 30, 2024
  4. Torsten BögershausenApr 30, 2024

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.