Skip to content

Commit

Permalink
init: do parse _all_ core.* settings early
Browse files Browse the repository at this point in the history
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 git-for-windows#3414

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
  • Loading branch information
dscho committed Apr 29, 2024
1 parent 9596ddb commit b125917
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
4 changes: 2 additions & 2 deletions config.c
Expand Up @@ -1374,8 +1374,8 @@ 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,
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")) {
Expand Down
2 changes: 2 additions & 0 deletions config.h
Expand Up @@ -167,6 +167,8 @@ typedef int (*config_fn_t)(const char *, const char *,

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);

/**
* Read a specific file in git-config format.
Expand Down
2 changes: 1 addition & 1 deletion setup.c
Expand Up @@ -2224,7 +2224,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);

Expand Down

0 comments on commit b125917

Please sign in to comment.