Subject: Re: [PATCH v2 2/5] environment.c: remove test-specific "ignore_untracked..." variable

From: Junio C Hamano <[email-masked]>
Date: Fri, 17 Sep 2021 10:19:10 -0700

Ævar Arnfjörð Bjarmason  <[email-masked]> writes:

> diff --git a/t/helper/test-dump-untracked-cache.c b/t/helper/test-dump-untracked-cache.c
> index cf0f2c7228e..99010614f6d 100644
> --- a/t/helper/test-dump-untracked-cache.c
> +++ b/t/helper/test-dump-untracked-cache.c
> @@ -45,8 +45,10 @@ int cmd__dump_untracked_cache(int ac, const char **av)
>  	struct untracked_cache *uc;
>  	struct strbuf base = STRBUF_INIT;
>  
> -	/* Hack to avoid modifying the untracked cache when we read it */
> -	ignore_untracked_cache_config = 1;
> +	/* Set core.untrackedCache=keep before setup_git_directory() */
> +	xsetenv("GIT_CONFIG_COUNT", "1", 1);
> +	xsetenv("GIT_CONFIG_KEY_0", "core.untrackedCache", 1);
> +	xsetenv("GIT_CONFIG_VALUE_0", "keep", 1);
>  
>  	setup_git_directory();
>  	if (read_cache() < 0)

If any parent process were using the GIT_CONFIG_* and the
GIT_CONFIG_PARAMETERS mechanism to pass one-shot config setting down
to a git subprocess, this obviously will break, but I would assume
that:

 (1) this test helper itself is not interested in being told to
     pretend any configuration other than what is found in the files
     are in effect, and

 (2) this test helper will not spawn git subprocesses that should
     honor the one-shot config setting whoever started the test
     helper wanted them to use.

So this should be an OK price to pay for being able to remove the
test-only code from the core part.

Looking good.