From 40e2919aa7c849ce13f8633bf602dc2f0d4d50f4 Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Wed, 8 Sep 2021 13:05:42 +0200 Subject: [PATCH] init: do parse _all_ core.* settings early In Git for Windows, `has_symlinks` is set to 0 by default. Therefore, we need to parse the config setting `core.symlinks` to know if it has been set to `true`. In `git init`, we must do that before copying the templates because they might contain symbolic links. Even if the support for symbolic links on Windows has not made it to upstream Git yet, we really should make sure that all the `core.*` settings are parsed before proceeding, as they might very well change the behavior of `git init` in a way the user intended. This fixes https://github.com/git-for-windows/git/issues/3414 Signed-off-by: Johannes Schindelin --- builtin/init-db.c | 2 +- config.c | 2 +- config.h | 1 + 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/builtin/init-db.c b/builtin/init-db.c index 2167796ff2aad0..c2ba56bb3f85b4 100644 --- a/builtin/init-db.c +++ b/builtin/init-db.c @@ -410,7 +410,7 @@ int init_db(const char *git_dir, const char *real_git_dir, startup_info->have_repository = 1; /* Ensure `core.hidedotfiles` is processed */ - git_config(platform_core_config, NULL); + git_config(git_default_core_config, NULL); safe_create_dir(git_dir, 0); diff --git a/config.c b/config.c index 2dcbe901b6b7a0..3f5a8e61fbb926 100644 --- a/config.c +++ b/config.c @@ -1276,7 +1276,7 @@ int git_config_color(char *dest, const char *var, const char *value) return 0; } -static int git_default_core_config(const char *var, const char *value, void *cb) +int git_default_core_config(const char *var, const char *value, void *cb) { /* This needs a better name */ if (!strcmp(var, "core.filemode")) { diff --git a/config.h b/config.h index f119de01309ccf..41754e19c46d7a 100644 --- a/config.h +++ b/config.h @@ -122,6 +122,7 @@ struct config_options { typedef int (*config_fn_t)(const char *, const char *, void *); int git_default_config(const char *, const char *, void *); +int git_default_core_config(const char *var, const char *value, void *cb); /** * Read a specific file in git-config format.