Skip to content

Commit c7d0e61

Browse files
tboegigitster
authored andcommitted
macOS: precompose startup_info->prefix
The "prefix" was precomposed for macOS in commit 5c32750 (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 <[email protected]> Helped-by: Junio C Hamano <[email protected]> Signed-off-by: Torsten Bögershausen <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 5020774 commit c7d0e61

File tree

2 files changed

+19
-11
lines changed

2 files changed

+19
-11
lines changed

git.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -420,7 +420,7 @@ static int run_builtin(struct cmd_struct *p, int argc, const char **argv)
420420
int nongit_ok;
421421
prefix = setup_git_directory_gently(&nongit_ok);
422422
}
423-
prefix = precompose_argv_prefix(argc, argv, prefix);
423+
precompose_argv_prefix(argc, argv, NULL);
424424
if (use_pager == -1 && p->option & (RUN_SETUP | RUN_SETUP_GENTLY) &&
425425
!(p->option & DELAY_PAGER_CONFIG))
426426
use_pager = check_pager_config(p->cmd);

setup.c

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1274,18 +1274,10 @@ const char *setup_git_directory_gently(int *nongit_ok)
12741274
* the GIT_PREFIX environment variable must always match. For details
12751275
* see Documentation/config/alias.txt.
12761276
*/
1277-
if (nongit_ok && *nongit_ok) {
1277+
if (nongit_ok && *nongit_ok)
12781278
startup_info->have_repository = 0;
1279-
startup_info->prefix = NULL;
1280-
setenv(GIT_PREFIX_ENVIRONMENT, "", 1);
1281-
} else {
1279+
else
12821280
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-
}
12891281

12901282
/*
12911283
* 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)
13111303
if (startup_info->have_repository)
13121304
repo_set_hash_algo(the_repository, repo_fmt.hash_algo);
13131305
}
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+
13141322

13151323
strbuf_release(&dir);
13161324
strbuf_release(&gitdir);

0 commit comments

Comments
 (0)