Merge branch 'gc/bare-repo-discovery'
Allow configuration files in "protected" scopes to include other configuration files. * gc/bare-repo-discovery: config: respect includes in protected config
This commit is contained in:
commit
777f548b5a
30
config.c
30
config.c
@ -2392,11 +2392,6 @@ int git_configset_add_file(struct config_set *cs, const char *filename)
|
|||||||
return git_config_from_file(config_set_callback, filename, cs);
|
return git_config_from_file(config_set_callback, filename, cs);
|
||||||
}
|
}
|
||||||
|
|
||||||
int git_configset_add_parameters(struct config_set *cs)
|
|
||||||
{
|
|
||||||
return git_config_from_parameters(config_set_callback, cs);
|
|
||||||
}
|
|
||||||
|
|
||||||
int git_configset_get_value(struct config_set *cs, const char *key, const char **value)
|
int git_configset_get_value(struct config_set *cs, const char *key, const char **value)
|
||||||
{
|
{
|
||||||
const struct string_list *values = NULL;
|
const struct string_list *values = NULL;
|
||||||
@ -2641,24 +2636,15 @@ int repo_config_get_pathname(struct repository *repo,
|
|||||||
/* Read values into protected_config. */
|
/* Read values into protected_config. */
|
||||||
static void read_protected_config(void)
|
static void read_protected_config(void)
|
||||||
{
|
{
|
||||||
char *xdg_config = NULL, *user_config = NULL, *system_config = NULL;
|
struct config_options opts = {
|
||||||
|
.respect_includes = 1,
|
||||||
|
.ignore_repo = 1,
|
||||||
|
.ignore_worktree = 1,
|
||||||
|
.system_gently = 1,
|
||||||
|
};
|
||||||
git_configset_init(&protected_config);
|
git_configset_init(&protected_config);
|
||||||
|
config_with_options(config_set_callback, &protected_config,
|
||||||
system_config = git_system_config();
|
NULL, &opts);
|
||||||
git_global_config(&user_config, &xdg_config);
|
|
||||||
|
|
||||||
if (system_config)
|
|
||||||
git_configset_add_file(&protected_config, system_config);
|
|
||||||
if (xdg_config)
|
|
||||||
git_configset_add_file(&protected_config, xdg_config);
|
|
||||||
if (user_config)
|
|
||||||
git_configset_add_file(&protected_config, user_config);
|
|
||||||
git_configset_add_parameters(&protected_config);
|
|
||||||
|
|
||||||
free(system_config);
|
|
||||||
free(xdg_config);
|
|
||||||
free(user_config);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void git_protected_config(config_fn_t fn, void *data)
|
void git_protected_config(config_fn_t fn, void *data)
|
||||||
|
@ -71,4 +71,13 @@ test_expect_success 'safe.directory=*, but is reset' '
|
|||||||
expect_rejected_dir
|
expect_rejected_dir
|
||||||
'
|
'
|
||||||
|
|
||||||
|
test_expect_success 'safe.directory in included file' '
|
||||||
|
cat >gitconfig-include <<-EOF &&
|
||||||
|
[safe]
|
||||||
|
directory = "$(pwd)"
|
||||||
|
EOF
|
||||||
|
git config --global --add include.path "$(pwd)/gitconfig-include" &&
|
||||||
|
git status
|
||||||
|
'
|
||||||
|
|
||||||
test_done
|
test_done
|
||||||
|
@ -51,4 +51,13 @@ test_expect_success 'safe.bareRepository on the command line' '
|
|||||||
-c safe.bareRepository=all
|
-c safe.bareRepository=all
|
||||||
'
|
'
|
||||||
|
|
||||||
|
test_expect_success 'safe.bareRepository in included file' '
|
||||||
|
cat >gitconfig-include <<-\EOF &&
|
||||||
|
[safe]
|
||||||
|
bareRepository = explicit
|
||||||
|
EOF
|
||||||
|
git config --global --add include.path "$(pwd)/gitconfig-include" &&
|
||||||
|
expect_rejected -C outer-repo/bare-repo
|
||||||
|
'
|
||||||
|
|
||||||
test_done
|
test_done
|
||||||
|
Loading…
Reference in New Issue
Block a user