Re: [PATCH v2 08/21] config: make dependency on repo in `read_early_config()` explicit

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri Aug 30, 2024 at 7:09 PM AEST, Patrick Steinhardt wrote:
> diff --git a/config.c b/config.c
> index a8357ea9544..043e1c8a078 100644
> --- a/config.c
> +++ b/config.c
> @@ -6,8 +6,6 @@
>   *
>   */
>  
> -#define USE_THE_REPOSITORY_VARIABLE
> -
>  #include "git-compat-util.h"
>  #include "abspath.h"
>  #include "advice.h"
> @@ -2204,7 +2202,7 @@ static void configset_iter(struct config_set *set, config_fn_t fn, void *data)
>  	}
>  }
>  
> -void read_early_config(config_fn_t cb, void *data)
> +void read_early_config(struct repository *repo, config_fn_t cb, void *data)
>  {
>  	struct config_options opts = {0};
>  	struct strbuf commondir = STRBUF_INIT;
> @@ -2212,9 +2210,9 @@ void read_early_config(config_fn_t cb, void *data)
>  
>  	opts.respect_includes = 1;
>  
> -	if (have_git_dir()) {
> -		opts.commondir = repo_get_common_dir(the_repository);
> -		opts.git_dir = repo_get_git_dir(the_repository);
> +	if (repo && repo->gitdir) {
> +		opts.commondir = repo_get_common_dir(repo);
> +		opts.git_dir = repo_get_git_dir(repo);
>  	/*
>  	 * When setup_git_directory() was not yet asked to discover the
>  	 * GIT_DIR, we ask discover_git_directory() to figure out whether there

It doesn't really matter either way since we perform the same checks, but should we do

        if (repo && repo_get_git_dir(repo))

instead of accessing the field directly?






[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux