]> git.ipfire.org Git - thirdparty/git.git/commitdiff
init: do parse _all_ core.* settings early
authorJohannes Schindelin <johannes.schindelin@gmx.de>
Tue, 16 Dec 2025 15:33:46 +0000 (15:33 +0000)
committerJunio C Hamano <gitster@pobox.com>
Wed, 17 Dec 2025 23:21:06 +0000 (08:21 +0900)
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 <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
environment.c
environment.h
setup.c

index a770b5921d9546818b350157f7b4501db1261f4c..b65b85a01f18cfd90a8f4d3ce6b187bf4f675826 100644 (file)
@@ -324,8 +324,8 @@ next_name:
        return (current & ~negative) | positive;
 }
 
-static int git_default_core_config(const char *var, const char *value,
-                                  const struct config_context *ctx, void *cb)
+int git_default_core_config(const char *var, const char *value,
+                           const struct config_context *ctx, void *cb)
 {
        /* This needs a better name */
        if (!strcmp(var, "core.filemode")) {
index 51898c99cd1e451a47c1a4aae32869cfbddbce45..e61f843fdbb637235d41229e12213c2bbeb3e242 100644 (file)
@@ -106,6 +106,8 @@ const char *strip_namespace(const char *namespaced_ref);
 
 int git_default_config(const char *, const char *,
                       const struct config_context *, void *);
+int git_default_core_config(const char *var, const char *value,
+                           const struct config_context *ctx, void *cb);
 
 /*
  * TODO: All the below state either explicitly or implicitly relies on
diff --git a/setup.c b/setup.c
index 3a6a048620dd7d5046d6ed5c04f126322e6a7618..b723f8b33931bd22246d4120afed3b7bef59c8ae 100644 (file)
--- a/setup.c
+++ b/setup.c
@@ -2693,7 +2693,7 @@ int init_db(const char *git_dir, const char *real_git_dir,
         * have set up the repository format such that we can evaluate
         * includeIf conditions correctly in the case of re-initialization.
         */
-       repo_config(the_repository, platform_core_config, NULL);
+       repo_config(the_repository, git_default_core_config, NULL);
 
        safe_create_dir(the_repository, git_dir, 0);