diff options
author | Victoria Dye <vdye@github.com> | 2023-05-26 04:33:00 +0300 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2023-05-26 07:53:41 +0300 |
commit | 3867f6d650c89230ae7393e2d57160ccc14758c7 (patch) | |
tree | 967a2971733b17b584c01943116e39264203f38a /config.c | |
parent | 9b6b06c159e0a389aaafbce91dd85bb5244ac5ad (diff) |
repository: move 'repository_format_worktree_config' to repo scope
Move 'repository_format_worktree_config' out of the global scope and into
the 'repository' struct. This change is similar to how
'repository_format_partial_clone' was moved in ebaf3bcf1ae (repository: move
global r_f_p_c to repo struct, 2021-06-17), adding it to the 'repository'
struct and updating 'setup.c' & 'repository.c' functions to assign the value
appropriately.
The primary goal of this change is to be able to load the worktree config of
a submodule depending on whether that submodule - not its superproject - has
'extensions.worktreeConfig' enabled. To ensure 'do_git_config_sequence()'
has access to the newly repo-scoped configuration, add a 'struct repository'
argument to 'do_git_config_sequence()' and pass it the 'repo' value from
'config_with_options()'.
Finally, add/update tests in 't3007-ls-files-recurse-submodules.sh' to
verify 'extensions.worktreeConfig' is read an used independently by
superprojects and submodules.
Signed-off-by: Victoria Dye <vdye@github.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'config.c')
-rw-r--r-- | config.c | 7 |
1 files changed, 4 insertions, 3 deletions
@@ -2195,6 +2195,7 @@ int git_config_system(void) static int do_git_config_sequence(struct config_reader *reader, const struct config_options *opts, + const struct repository *repo, config_fn_t fn, void *data) { int ret = 0; @@ -2243,7 +2244,7 @@ static int do_git_config_sequence(struct config_reader *reader, config_reader_set_scope(reader, CONFIG_SCOPE_WORKTREE); if (!opts->ignore_worktree && worktree_config && - repository_format_worktree_config && + repo && repo->repository_format_worktree_config && !access_or_die(worktree_config, R_OK, 0)) { ret += git_config_from_file(fn, worktree_config, data); } @@ -2296,7 +2297,7 @@ int config_with_options(config_fn_t fn, void *data, ret = git_config_from_blob_ref(fn, repo, config_source->blob, data); } else { - ret = do_git_config_sequence(&the_reader, opts, fn, data); + ret = do_git_config_sequence(&the_reader, opts, repo, fn, data); } if (inc.remote_urls) { @@ -3339,7 +3340,7 @@ int repo_config_set_worktree_gently(struct repository *r, const char *key, const char *value) { /* Only use worktree-specific config if it is already enabled. */ - if (repository_format_worktree_config) { + if (r->repository_format_worktree_config) { char *file = repo_git_path(r, "config.worktree"); int ret = git_config_set_multivar_in_file_gently( file, key, value, NULL, 0); |