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

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

From
Torsten Bögershausen <tboegi@web.de>
Date
Apr 30, 2024, 16:58 UTC
Message-ID
<20240430165831.GA3546@tb-raspi4>
In-Reply-To
<44EB4C2D-5C86-4448-B8D8-3E90F75DB5CB@kba.biglobe.ne.jp>
On Wed, May 01, 2024 at 12:52:38AM +0900, Jun. T wrote:
Show 41 quoted lines
>
> > 2024/04/30 16:12, Torsten Bögershausen <tboegi@web.de> 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)
>

Thanks for digging - I have spend some time to find the cause, but no success yet. There is even a set_git_work_tree() in environment.c, and that may need some treatment - or some other place. To be continued - I will continue digging, where the NFD comes into Git.

Previous: Jun. T
Message 4 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.