]> git.ipfire.org Git - thirdparty/git.git/commitdiff
macOS: precompose startup_info->prefix
authorTorsten Bögershausen <tboegi@web.de>
Sun, 4 Apr 2021 17:14:14 +0000 (19:14 +0200)
committerJunio C Hamano <gitster@pobox.com>
Tue, 6 Apr 2021 00:30:36 +0000 (17:30 -0700)
The "prefix" was precomposed for macOS in commit 5c327502 (MacOS:
precompose_argv_prefix(), 2021-02-03).

However, this commit forgot to update "startup_info->prefix" after
precomposing.

Move the (possible) precomposition towards the end of
setup_git_directory_gently(), so that precompose_string_if_needed()
can use git_config_get_bool("core.precomposeunicode") correctly.

Keep prefix, startup_info->prefix and GIT_PREFIX_ENVIRONMENT all in sync.

And as a result, the prefix no longer needs to be precomposed in git.c

Reported-by: Dmitry Torilov <d.torilov@gmail.com>
Helped-by: Junio C Hamano <gitster@pobox.com>
Signed-off-by: Torsten Bögershausen <tboegi@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
git.c
setup.c

diff --git a/git.c b/git.c
index 16a485fbe747be3db6d895f1e6faa43cd63c608c..3d7eabef9720fa2a80b17f99eb53c21f0c656e2c 100644 (file)
--- a/git.c
+++ b/git.c
@@ -420,7 +420,7 @@ static int run_builtin(struct cmd_struct *p, int argc, const char **argv)
                        int nongit_ok;
                        prefix = setup_git_directory_gently(&nongit_ok);
                }
-               prefix = precompose_argv_prefix(argc, argv, prefix);
+               precompose_argv_prefix(argc, argv, NULL);
                if (use_pager == -1 && p->option & (RUN_SETUP | RUN_SETUP_GENTLY) &&
                    !(p->option & DELAY_PAGER_CONFIG))
                        use_pager = check_pager_config(p->cmd);
diff --git a/setup.c b/setup.c
index c04cd25a30dfe0e97d93087c0e7f29910d1b46a5..59e2facd9db6710eecb16d58714d154000198c08 100644 (file)
--- a/setup.c
+++ b/setup.c
@@ -1274,18 +1274,10 @@ const char *setup_git_directory_gently(int *nongit_ok)
         * the GIT_PREFIX environment variable must always match. For details
         * see Documentation/config/alias.txt.
         */
-       if (nongit_ok && *nongit_ok) {
+       if (nongit_ok && *nongit_ok)
                startup_info->have_repository = 0;
-               startup_info->prefix = NULL;
-               setenv(GIT_PREFIX_ENVIRONMENT, "", 1);
-       } else {
+       else
                startup_info->have_repository = 1;
-               startup_info->prefix = prefix;
-               if (prefix)
-                       setenv(GIT_PREFIX_ENVIRONMENT, prefix, 1);
-               else
-                       setenv(GIT_PREFIX_ENVIRONMENT, "", 1);
-       }
 
        /*
         * Not all paths through the setup code will call 'set_git_dir()' (which
@@ -1311,6 +1303,22 @@ const char *setup_git_directory_gently(int *nongit_ok)
                if (startup_info->have_repository)
                        repo_set_hash_algo(the_repository, repo_fmt.hash_algo);
        }
+       /*
+        * Since precompose_string_if_needed() needs to look at
+        * the core.precomposeunicode configuration, this
+        * has to happen after the above block that finds
+        * out where the repository is, i.e. a preparation
+        * for calling git_config_get_bool().
+        */
+       if (prefix) {
+               prefix = precompose_string_if_needed(prefix);
+               startup_info->prefix = prefix;
+               setenv(GIT_PREFIX_ENVIRONMENT, prefix, 1);
+       } else {
+               startup_info->prefix = NULL;
+               setenv(GIT_PREFIX_ENVIRONMENT, "", 1);
+       }
+
 
        strbuf_release(&dir);
        strbuf_release(&gitdir);