tboegi@xxxxxx writes: > From: Torsten Bögershausen <tboegi@xxxxxx> > > Under macOS, `git ls-files path` does not work (gives an error) > if the absolute 'path' contains characters in NFD (decomposed). > ... > > Reported-by: Jun T <takimoto-j@xxxxxxxxxxxxxxxxx> > Signed-off-by: Torsten Bögershausen <tboegi@xxxxxx> > --- Looks good. I've queued with a slight rewording to the proposed log message, and a bit of extra quoting in the test. Any string that contains "$aumlcdiar" are enclosed in a pair of double-quotes in the script, so not just the one given to ls-files, other two references to it are also quoted now. Thanks. 1: a00cec23cf ! 1: ee6ba4053d macOS: ls-files path fails if path of workdir is NFD @@ Commit message In the 'fatal:' error message, there are three ü; the 1st and 2nd are in NFC, the 3rd is in NFD. - This commit adds a test case that follows the bug report, - with the simplification that the 'ü' is replaced by an 'ä', - which is already used as NFD and NFC in t0050. + Add a test case that follows the bug report, with the simplification + that the 'ü' is replaced by an 'ä', which is already used as NFD and + NFC in t0050. - The solution is to precompose the result of getcwd(), if needed. + Precompose the result of getcwd(), if needed, just like all other + paths we use internally. That way, paths comparisons are all done + in NFC and we would correctly notice that the early part of the + path given as an absolute path matches the current directory. One possible implementation would be to re-define getcwd() similar - to opendir(), readdir() and closedir(). - Since there is already a strbuf wrapper around getcwd(), and only this - wrapper is used inside the whole codebase, equip strbuf_getcwd() with - a call to the newly created function precompose_strbuf_if_needed(). + to opendir(), readdir() and closedir(), but since there is already a + strbuf wrapper around getcwd(), and only this wrapper is used inside + the whole codebase, equip strbuf_getcwd() with a call to the newly + created function precompose_strbuf_if_needed(). + Note that precompose_strbuf_if_needed() is a function under macOS, and is a "no-op" on all other systems. @@ t/t0050-filesystem.sh: test_expect_success CASE_INSENSITIVE_FS 'checkout with no +test_expect_success 'git ls-files under NFD' ' + ( -+ mkdir -p somewhere/$aumlcdiar && ++ mkdir -p "somewhere/$aumlcdiar" && + mypwd=$PWD && -+ cd somewhere/$aumlcdiar && ++ cd "somewhere/$aumlcdiar" && + git init && -+ git --literal-pathspecs ls-files "$mypwd/somewhere/$aumlcdiar" 2>err && ++ git --literal-pathspecs ls-files "$mypwd/somewhere/$aumlcdiar" 2>err && + >expected && + test_cmp expected err + )