From: Jun. T Date: Tue, 30 Apr 2024 15:52:38 GMT Subject: Re: [BUG] 'ls-files path' fails if absolute path of workdir contains NFD (macOS) Message-ID: <44EB4C2D-5C86-4448-B8D8-3E90F75DB5CB@kba.biglobe.ne.jp> In-Reply-To: <20240430071247.GB1504@tb-raspi4> > 2024/04/30 16:12, Torsten Bögershausen wrote: > > I am familar with the NFC/NFD stuff, but not with get_git_work_tree(), > at least not yet. > > If you have a suggestion for a patch, would you like to share it ? Well, the only thing I can tell is the patch below _seems_ to fix the _current_ problem. There may be other problems, it may introduce new problem(s) (such as memory leak), etc. But I don't know anything about the git internals and have no time now to investigate further. Sorry. get_git_work_tree() just returns the value of the_repository->worktree but I have no idea where this variable is set. get_git_work_tree() and the_repository->worktree are used in many places, and I'm not sure changing the function/variable has no bad side effects or not. And how to convert into NFC? By precompose_string_if_needed()? Does this function allocate a new memory for NFC? If so, do we need to free it at some point? diff --git a/setup.c b/setup.c index f4b32f76e3..3f2f3ed016 100644 --- a/setup.c +++ b/setup.c @@ -47,7 +47,7 @@ static int abspath_part_inside_repo(char *path) size_t wtlen; char *path0; int off; - const char *work_tree = get_git_work_tree(); + const char *work_tree = precompose_string_if_needed(get_git_work_tree()); struct strbuf realpath = STRBUF_INIT; if (!work_tree)