macOS: precompose startup_info->prefix
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>
Torsten Bögershausen committed
Apr 4, 2021 at 19:14 UTC
c7d0e61016bfa1c6aec04b0d7daec2e64cfccf3e
2 files changed
+19
-11
git.c
+1
-1
@@ -420,7 +420,7 @@ static int run_builtin(struct cmd_struct *p, int argc, const char **argv)
420
int nongit_ok;
421
prefix = setup_git_directory_gently(&nongit_ok);
422
}
423
- prefix = precompose_argv_prefix(argc, argv, prefix);
423
+ precompose_argv_prefix(argc, argv, NULL);
424
if (use_pager == -1 && p->option & (RUN_SETUP | RUN_SETUP_GENTLY) &&
425
!(p->option & DELAY_PAGER_CONFIG))
426
use_pager = check_pager_config(p->cmd);
setup.c
+18
-10
@@ -1274,18 +1274,10 @@ const char *setup_git_directory_gently(int *nongit_ok)
1274
* the GIT_PREFIX environment variable must always match. For details
1275
* see Documentation/config/alias.txt.
1276
*/
1277
- if (nongit_ok && *nongit_ok) {
1277
+ if (nongit_ok && *nongit_ok)
1278
startup_info->have_repository = 0;
1279
- startup_info->prefix = NULL;
1280
- setenv(GIT_PREFIX_ENVIRONMENT, "", 1);
1281
- } else {
1279
+ else
1280
startup_info->have_repository = 1;
1283
- startup_info->prefix = prefix;
1284
- if (prefix)
1285
- setenv(GIT_PREFIX_ENVIRONMENT, prefix, 1);
1286
- else
1287
- setenv(GIT_PREFIX_ENVIRONMENT, "", 1);
1288
- }
1281
1282
/*
1283
* 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)
1303
if (startup_info->have_repository)
1304
repo_set_hash_algo(the_repository, repo_fmt.hash_algo);
1305
}
1306
+ /*
1307
+ * Since precompose_string_if_needed() needs to look at
1308
+ * the core.precomposeunicode configuration, this
1309
+ * has to happen after the above block that finds
1310
+ * out where the repository is, i.e. a preparation
1311
+ * for calling git_config_get_bool().
1312
+ */
1313
+ if (prefix) {
1314
+ prefix = precompose_string_if_needed(prefix);
1315
+ startup_info->prefix = prefix;
1316
+ setenv(GIT_PREFIX_ENVIRONMENT, prefix, 1);
1317
+ } else {
1318
+ startup_info->prefix = NULL;
1319
+ setenv(GIT_PREFIX_ENVIRONMENT, "", 1);
1320
+ }
1321
+
1322
1323
strbuf_release(&dir);
1324
strbuf_release(&gitdir);