git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Torsten Bögershausen" <tboegi@web.de>
To: "Jun. T" <takimoto-j@kba.biglobe.ne.jp>
Cc: git@vger.kernel.org
Subject: Re: [PATCH v2 1/1] macOS: ls-files path fails if path of workdir is NFD
Date: Mon, 20 May 2024 18:06:01 +0200	[thread overview]
Message-ID: <20240520160601.GA29154@tb-raspi4> (raw)
In-Reply-To: <98AD4B35-ECE2-4349-AEA9-86F5CA52EA9B@kba.biglobe.ne.jp>

On Sun, May 19, 2024 at 04:03:03PM +0900, Jun. T wrote:
> Sorry for not responding quickly.
>
> Thank you for the patch, but it seems the problem still remains.
>
> Although
> % git ls-files NFD
> (apparently) works,
> % git ls-files NFC
> still gives the error
> (if core.precomposeunicode is not set in global config).
>
> The following is some info I got (hope it is correct and useful),
> but I have no idea how to fix the problem.
>
> precompose_string_if_needed() works only if:
>   precomposed_unicode is already set to 1, or
>   git_config_get_bool("core.precomposeunicode") sets it to 1.
>
> But git_config_get_bool() reads the file .git/config only if:
>   the_repository->commondir is already set to ".git".
>
> Back trace when the strbuf_getcwd() is called for the
> 3rd time is (frame #4 is set_git_work_tree()):
>
>   * frame #0: git`strbuf_getcwd(sb=0x00007ff7bfeff0a8) at strbuf.c:588:20
>     frame #1: git`strbuf_realpath_1(resolved=0x00007ff7bfeff0a8, path=".", flags=2) at abspath.c:101:7
>     frame #2: git`strbuf_realpath(resolved=0x00007ff7bfeff0a8, path=".", die_on_error=1) at abspath.c:219:9
>     frame #3: git`real_pathdup(path=".", die_on_error=1) at abspath.c:240:6
>     frame #4: git`repo_set_worktree(repo=0x000000010044eb98, path=".") at repository.c:145:19
>     frame #5: git`set_git_work_tree(new_work_tree=".") at environment.c:278:2
>     frame #6: git`setup_discovered_git_dir(gitdir=".git", cwd=0x0000000100435238, offset=16, repo_fmt=0x00007ff7bfeff1d8, nongit_ok=0x0000000000000000) at setup.c:1119:2
>     frame #7: git`setup_git_directory_gently(nongit_ok=0x0000000000000000) at setup.c:1606:12
>     frame #8: git`setup_git_directory at setup.c:1815:9
>     frame #9: git`run_builtin(p=0x0000000100424d58, argc=2, argv=0x00007ff7bfeff6d8) at git.c:448:12
>     frame #10: git`handle_builtin(argc=2, argv=0x00007ff7bfeff6d8) at git.c:729:3
>     frame #11: git`run_argv(argcp=0x00007ff7bfeff54c, argv=0x00007ff7bfeff540) at git.c:793:4
>     frame #12: git`cmd_main(argc=2, argv=0x00007ff7bfeff6d8) at git.c:928:19
>     frame #13: git`main(argc=3, argv=0x00007ff7bfeff6d0) at common-main.c:62:11
>
> At this point, precomposed_unicode is still -1 and
> the_repository->commondir is still NULL.
> This means strbuf_getcwd() retuns NFD, and                                      the_repository->worktree is set to NFD.
>
> Moreover, precompose_string_if_needed() calls
> git_config_get_bool("core.precomposeunicode"), and
> this function indirecly sets
> the_repository->config->hash_initialized = 1
>
> Later setup_git_directory_gently() (frame #7) calls
> setup_git_env() --> repo_set_gitdir() --> repo_set_commondir()
> and the_repository->commondir is now set to ".git".
>
> Then run_builtin() (frame #10) calls precompose_argv_prefix()
>  --> precompose_string_if_needed(). Here we have
>   precomposed_unicode = -1
>   the_repository->config->hash_initialized = 1
> This means git_config_check_init() does not read
> .git/config (does not call repo_read_config()) even if
> the_repository->commondir is set to ".git",
> and precomposed_unicode is not set to 1.
> So the NFD in argv is not converted to NFC,
> and
> % git ls-files NFD
> apparently works.
>

Thanks so much for the detailed analysis, that is appreciated.
To be honest, I have set core.precomposeunicode true globally,
core.quotepath=false, together with settings for
pull.rebase and init.defaultbranch

Because of that, the new testcase passed, and the patch was in
improvement.
However, it would be nice to have the case fixed as well,
where core.precomposeunicode is not set at a global level.

I am happy to provide a patch (a new testcase is already there),
but for a change in the codebase I would need some help from an expert,
to get the config-reading right both for hash_initialized
(that is may be not about the hash-algorithn at all ?)
and precompose.






  reply	other threads:[~2024-05-20 16:06 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20240430032717281.IXLP.121462.mail.biglobe.ne.jp@biglobe.ne.jp>
2024-05-07  8:44 ` [PATCH v1 1/2] t0050: ls-files path fails if path of workdir is NFD tboegi
2024-05-07 17:30   ` Junio C Hamano
2024-05-07  8:44 ` [PATCH v1 2/2] strbuf_getcwd() needs precompse_strbuf_if_needed() tboegi
2024-05-07 17:22   ` Junio C Hamano
2024-05-09 15:24     ` Junio C Hamano
2024-05-09 15:29       ` Torsten Bögershausen
2024-05-07 17:47   ` Junio C Hamano
2024-05-08  0:32     ` brian m. carlson
2024-05-09 16:11 ` [PATCH v2 1/1] macOS: ls-files path fails if path of workdir is NFD tboegi
2024-05-09 16:37   ` Junio C Hamano
2024-05-19  7:03   ` Jun. T
2024-05-20 16:06     ` Torsten Bögershausen [this message]
2024-05-20 18:08       ` Junio C Hamano
2024-05-20 19:21         ` Torsten Bögershausen
2024-05-21 14:14 ` [PATCH v3 " tboegi
2024-05-21 17:50   ` Junio C Hamano
2024-05-21 20:57     ` Torsten Bögershausen
2024-05-21 22:15       ` Junio C Hamano
2024-05-23 15:33         ` Jun. T
2024-05-25 20:01           ` Torsten Bögershausen
2024-05-31 19:31 ` [PATCH v4 " tboegi
2024-06-01 15:55   ` Junio C Hamano
2024-06-02 19:40     ` Torsten Bögershausen
2024-06-04  0:56   ` Jun T

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240520160601.GA29154@tb-raspi4 \
    --to=tboegi@web.de \
    --cc=git@vger.kernel.org \
    --cc=takimoto-j@kba.biglobe.ne.jp \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).