git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 2/5] init: do parse _all_ core.* settings early

From
Johannes Schindelin via GitGitGadget <gitgitgadget@gmail.com>
Date
Dec 16, 2025, 15:33 UTC
Message-ID
<31497b019886698aacebbbc6a464a7c0124f31c4.1765899229.git.gitgitgadget@gmail.com>
In-Reply-To
<pull.2017.git.1765899229.gitgitgadget@gmail.com>
From: Johannes Schindelin <johannes.schindelin@gmx.de>

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>
---
 environment.c | 4 ++--
 environment.h | 2 ++
 setup.c       | 2 +-
 3 files changed, 5 insertions(+), 3 deletions(-)
diff --git a/environment.c b/environment.c
index a770b5921d..b65b85a01f 100644
--- a/environment.c
+++ b/environment.c
@@ -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")) {
diff --git a/environment.h b/environment.h
index 51898c99cd..e61f843fdb 100644
--- a/environment.h
+++ b/environment.h
@@ -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 7086741e6c..42e4e7a690 100644
--- a/setup.c
+++ b/setup.c
@@ -2611,7 +2611,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);
 
-- 
gitgitgadget
Previous: Patrick SteinhardtNext: Patrick Steinhardt
Message 4 of 21 in “Last preparations before upstreaming Git for Windows' symlink support”
  1. 0/5 Last preparations before upstreaming Git for Windows' symlink supportJohannes Schindelin via GitGitGadget, Dec 16, 2025
  2. 1/5 mingw: do resolve symlinks in `getcwd()`Johannes Schindelin via GitGitGadget, Dec 16, 2025
  3. Patrick SteinhardtDec 17, 2025
  4. 2/5 init: do parse _all_ core.* settings earlyJohannes Schindelin via GitGitGadget, Dec 16, 2025
  5. Patrick SteinhardtDec 17, 2025
  6. 3/5 strbuf_readlink(): avoid calling `readlink()` twice in corner-casesKarsten Blees via GitGitGadget, Dec 16, 2025
  7. 4/5 strbuf_readlink(): support link targets that exceed PATH_MAXKarsten Blees via GitGitGadget, Dec 16, 2025
  8. Patrick SteinhardtDec 17, 2025
  9. Johannes SchindelinDec 19, 2025
  10. Patrick SteinhardtDec 19, 2025
  11. Junio C HamanoDec 30, 2025
  12. Junio C HamanoDec 17, 2025
  13. 5/5 trim_last_path_component(): avoid hard-coding the directory separatorKarsten Blees via GitGitGadget, Dec 16, 2025
  14. 0/5 Last preparations before upstreaming Git for Windows' symlink supportJohannes Schindelin via GitGitGadget, Jan 9, 2026
  15. 1/5 mingw: do resolve symlinks in `getcwd()`Johannes Schindelin via GitGitGadget, Jan 9, 2026
  16. 2/5 init: do parse _all_ core.* settings earlyJohannes Schindelin via GitGitGadget, Jan 9, 2026
  17. 3/5 strbuf_readlink(): avoid calling `readlink()` twice in corner-casesKarsten Blees via GitGitGadget, Jan 9, 2026
  18. 4/5 strbuf_readlink(): support link targets that exceed 2*PATH_MAXJohannes Schindelin via GitGitGadget, Jan 9, 2026
  19. 5/5 trim_last_path_component(): avoid hard-coding the directory separatorKarsten Blees via GitGitGadget, Jan 9, 2026
  20. Junio C HamanoJan 11, 2026
  21. Patrick SteinhardtJan 12, 2026

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.