Git Mailing List Archive mirror
 help / color / mirror / Atom feed
From: Derrick Stolee <derrickstolee@github.com>
To: Victoria Dye via GitGitGadget <gitgitgadget@gmail.com>,
	git@vger.kernel.org
Cc: chooglen@google.com, Victoria Dye <vdye@github.com>
Subject: Re: [PATCH 2/2] repository: move 'repository_format_worktree_config' to repo scope
Date: Thu, 25 May 2023 16:13:44 -0400	[thread overview]
Message-ID: <4d8907ba-3fe5-5bc1-e7bd-237edec31261@github.com> (raw)
In-Reply-To: <5ed9100a7707a529b309005419244d083cdc85ba.1684883872.git.gitgitgadget@gmail.com>

On 5/23/2023 7:17 PM, Victoria Dye via GitGitGadget wrote:
> From: Victoria Dye <vdye@github.com>
> 
> 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 to the 'repository'
> struct and updating 'setup.c' & 'repository.c' functions to assign the value
> appropriately. In addition, update usage of the setting to reference the
> relevant context's repo or, as a fallback, 'the_repository'.
> 
> The primary goal of this change is to be able to load worktree config for a
> submodule depending on whether that submodule - not the super project - has
> 'extensions.worktreeConfig' enabled. To ensure 'do_git_config_sequence()'
> has access to the newly repo-scoped configuration:
> 
> - update 'repo_read_config()' to create a 'config_source' to hold the
>   repo instance
> - add a 'repo' argument to 'do_git_config_sequence()'
> - update 'config_with_options' to call 'do_git_config_sequence()' with
>   'config_source.repo', or 'the_repository' as a fallback
> 
> Finally, add/update tests in 't3007-ls-files-recurse-submodules.sh' to
> verify 'extensions.worktreeConfig' is read an used independently by super
> projects and submodules.
 
> @@ -2277,7 +2278,7 @@ int config_with_options(config_fn_t fn, void *data,
>  		data = &inc;
>  	}
>  
> -	if (config_source)
> +	if (config_source && config_source->scope != CONFIG_SCOPE_UNKNOWN)
>  		config_reader_set_scope(&the_reader, config_source->scope);

This extra condition on config_source->scope surprised me. Could you
elaborate on the reason this is necessary?

> @@ -2667,11 +2670,14 @@ static void repo_read_config(struct repository *repo)
>  {
>  	struct config_options opts = { 0 };
>  	struct configset_add_data data = CONFIGSET_ADD_INIT;
> +	struct git_config_source config_source = { 0 };

This could be...

	struct git_config_source config_source = { .repo = repo };

>  
>  	opts.respect_includes = 1;
>  	opts.commondir = repo->commondir;
>  	opts.git_dir = repo->gitdir;
>  
> +	config_source.repo = repo;
> +

...avoiding these lines.

> diff --git a/t/t3007-ls-files-recurse-submodules.sh b/t/t3007-ls-files-recurse-submodules.sh
> index e35c203241f..6d0bacef4de 100755
> --- a/t/t3007-ls-files-recurse-submodules.sh
> +++ b/t/t3007-ls-files-recurse-submodules.sh
> @@ -309,19 +309,30 @@ test_expect_success '--recurse-submodules parses submodule repo config' '
>  test_expect_success '--recurse-submodules parses submodule worktree config' '
>  	test_when_finished "git -C submodule config --unset extensions.worktreeConfig" &&
>  	test_when_finished "git -C submodule config --worktree --unset feature.experimental" &&
> -	test_when_finished "git config --unset extensions.worktreeConfig" &&
>  
>  	git -C submodule config extensions.worktreeConfig true &&
>  	git -C submodule config --worktree feature.experimental "invalid non-boolean value" &&
>  
> -	# NEEDSWORK: the extensions.worktreeConfig is set globally based on super
> -	# project, so we need to enable it in the super project.
> -	git config extensions.worktreeConfig true &&
> -
>  	test_must_fail git ls-files --recurse-submodules 2>err &&
>  	grep "bad boolean config value" err
>  '

These are my favorite kind of test updates: deleting extra setup that's no
longer needed.

> +test_expect_success '--recurse-submodules submodules ignore super project worktreeConfig extension' '
> +	test_when_finished "git config --unset extensions.worktreeConfig" &&
> +
> +	# Enable worktree config in both super project & submodule, set an
> +	# invalid config in the submodule worktree config, then disable worktree
> +	# config in the submodule. The invalid worktree config should not be
> +	# picked up.
> +	git config extensions.worktreeConfig true &&
> +	git -C submodule config extensions.worktreeConfig true &&
> +	git -C submodule config --worktree feature.experimental "invalid non-boolean value" &&
> +	git -C submodule config --unset extensions.worktreeConfig &&
> +
> +	git ls-files --recurse-submodules 2>err &&
> +	! grep "bad boolean config value" err
> +'

We have the same ways to improve here using 'test_config' as recommended
in patch 1.

Thanks,
-Stolee

  parent reply	other threads:[~2023-05-25 20:13 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-23 23:17 [PATCH 0/2] Fix behavior of worktree config in submodules Victoria Dye via GitGitGadget
2023-05-23 23:17 ` [PATCH 1/2] config: use gitdir to get worktree config Victoria Dye via GitGitGadget
2023-05-25  1:05   ` Glen Choo
2023-05-25 20:05     ` Derrick Stolee
2023-05-23 23:17 ` [PATCH 2/2] repository: move 'repository_format_worktree_config' to repo scope Victoria Dye via GitGitGadget
2023-05-25  1:29   ` Glen Choo
2023-05-25 16:09     ` Glen Choo
2023-05-25 20:02       ` Victoria Dye
2023-05-25 20:13   ` Derrick Stolee [this message]
2023-05-24 10:25 ` [PATCH 0/2] Fix behavior of worktree config in submodules Junio C Hamano
2023-05-25 19:56 ` Glen Choo
2023-05-26  1:32 ` [PATCH v2 0/3] " Victoria Dye via GitGitGadget
2023-05-26  1:32   ` [PATCH v2 1/3] config: use gitdir to get worktree config Victoria Dye via GitGitGadget
2023-05-26  1:32   ` [PATCH v2 2/3] config: pass 'repo' directly to 'config_with_options()' Victoria Dye via GitGitGadget
2023-05-26  1:33   ` [PATCH v2 3/3] repository: move 'repository_format_worktree_config' to repo scope Victoria Dye via GitGitGadget
2023-05-31 22:17     ` Glen Choo
2023-06-01  4:43       ` Junio C Hamano
2023-06-12 21:37         ` Glen Choo
2023-06-07 22:29       ` Victoria Dye
2023-06-12 18:10         ` Glen Choo
2023-06-12 19:45           ` Victoria Dye
2023-06-12 20:23             ` Glen Choo
2023-06-12 23:04               ` [PATCH] setup: copy repository_format using helper Glen Choo
2023-06-13  0:03                 ` Victoria Dye
2023-06-13 18:25                   ` Glen Choo
2023-06-13 19:45                     ` Junio C Hamano
2023-05-26 15:48   ` [PATCH v2 0/3] Fix behavior of worktree config in submodules Derrick Stolee
2023-06-13 22:09   ` Glen Choo
2023-06-13 22:17     ` Victoria Dye

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4d8907ba-3fe5-5bc1-e7bd-237edec31261@github.com \
    --to=derrickstolee@github.com \
    --cc=chooglen@google.com \
    --cc=git@vger.kernel.org \
    --cc=gitgitgadget@gmail.com \
    --cc=vdye@github.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).