From 3867f6d650c89230ae7393e2d57160ccc14758c7 Mon Sep 17 00:00:00 2001 From: Victoria Dye Date: Fri, 26 May 2023 01:33:00 +0000 Subject: 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 Signed-off-by: Junio C Hamano --- setup.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'setup.c') diff --git a/setup.c b/setup.c index 458582207e..d866395435 100644 --- a/setup.c +++ b/setup.c @@ -650,11 +650,10 @@ static int check_repository_format_gently(const char *gitdir, struct repository_ } repository_format_precious_objects = candidate->precious_objects; - repository_format_worktree_config = candidate->worktree_config; string_list_clear(&candidate->unknown_extensions, 0); string_list_clear(&candidate->v1_only_extensions, 0); - if (repository_format_worktree_config) { + if (candidate->worktree_config) { /* * pick up core.bare and core.worktree from per-worktree * config if present @@ -1423,6 +1422,9 @@ int discover_git_directory(struct strbuf *commondir, return -1; } + the_repository->repository_format_worktree_config = + candidate.worktree_config; + /* take ownership of candidate.partial_clone */ the_repository->repository_format_partial_clone = candidate.partial_clone; @@ -1560,6 +1562,8 @@ const char *setup_git_directory_gently(int *nongit_ok) } if (startup_info->have_repository) { repo_set_hash_algo(the_repository, repo_fmt.hash_algo); + the_repository->repository_format_worktree_config = + repo_fmt.worktree_config; /* take ownership of repo_fmt.partial_clone */ the_repository->repository_format_partial_clone = repo_fmt.partial_clone; @@ -1651,6 +1655,8 @@ void check_repository_format(struct repository_format *fmt) check_repository_format_gently(get_git_dir(), fmt, NULL); startup_info->have_repository = 1; repo_set_hash_algo(the_repository, fmt->hash_algo); + the_repository->repository_format_worktree_config = + fmt->worktree_config; the_repository->repository_format_partial_clone = xstrdup_or_null(fmt->partial_clone); clear_repository_format(&repo_fmt); -- cgit v1.2.3