git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: Pass or not to pass config environment down...

From
Jacob Keller <jacob.keller@gmail.com>
Date
Mar 23, 2021, 20:52 UTC
Message-ID
<CA+P7+xokjz-2nC5+F9HG0tBqS948uZcuq-1eY9uGuNyzbFGbZQ@mail.gmail.com>
In-Reply-To
<xmqqk0px3dfu.fsf@gitster.g>
On Tue, Mar 23, 2021 at 11:58 AM Junio C Hamano <gitster@pobox.com> wrote:
Show 16 quoted lines
>
> I was grepping around and found this piece of code today:
>
>         static void prepare_submodule_repo_env_no_git_dir(struct strvec *out)
>         {
>                 const char * const *var;
>
>                 for (var = local_repo_env; *var; var++) {
>                         if (strcmp(*var, CONFIG_DATA_ENVIRONMENT))
>                                 strvec_push(out, *var);
>                 }
>         }
>
> which tries to "unsetenv" the environment variables that pertain to
> the current repository listed in loocal_repo_env[], but makes
> exception for GIT_CONFIG_PARAMETERS.
Right. We need to unset some parameters, but not everything...
Show 15 quoted lines
>
> It originally came from 14111fc4 (git: submodule honor -c
> credential.* from command line, 2016-02-29) and later simplified by
> 89044baa (submodule: stop sanitizing config options, 2016-05-04).
>
> Now after d8d77153 (config: allow specifying config entries via
> envvar pairs, 2021-01-12), we have yet another way to pass a set of
> custom one-shot configuration via the environment variable, using
> GIT_CONFIG_COUNT (which is in local_repo_env[] and will be removed
> from the environment by this helper function), GIT_CONFIG_KEY_$n and
> GIT_CONFIG_VALUE_$n (which are unbound set and naturally not in
> local_repo_env[]).  Leaving the latter two exported will not hurt if
> we do intend to hide the custom configuration from the subprocess by
> unsetting GIT_CONFIG_COUNT, but should we be doing so?
>

I think it's a difficult question because if I recall, there was some question/concern about what values need to stay for the submodule vs which ones do not..?

Show 13 quoted lines
> There are many run_command() users that just pass local_repo_env[]
> to the child.env when running a subprocess.  Given that the code
> that works in a submodule, which presumably is THE primary target
> of the "we do not want to pass environment variables that pertain to
> the current repository but not to the repository the child process
> works in" consideration that the local_repo_env[] is about, does *not*
> want the GIT_CONFIG_PARAMETERS cleansed, I have to wonder if the
> environment variables (the original GIT_CONFIG_PARAMETERS as well as
> Patrick's GIT_CONFIG_{COUNT,KEY_$n,VALUE_$n}) should be in that
> local_repo_env[] array in the first place.  If we remove them, the
> above helper function can just go away and be replaced with the
> usual child.env = local_repo_env assignment like everybody else.
>

I think that makes a reasonable amount of sense. So if I understand right, this change makes it so that CONFIG_DATA_ENVIRONMENT and CONFIG_COUNT_ENVIRONMENT will no longer be forwarded? I guess I am a bit confused about the current status vs what we want here.

Show 18 quoted lines
> Comments?
>
>  environment.c | 2 --
>  1 file changed, 2 deletions(-)
>
> diff --git c/environment.c w/environment.c
> index 2f27008424..6dcee6a9c5 100644
> --- c/environment.c
> +++ w/environment.c
> @@ -116,8 +116,6 @@ static char *super_prefix;
>  const char * const local_repo_env[] = {
>         ALTERNATE_DB_ENVIRONMENT,
>         CONFIG_ENVIRONMENT,
> -       CONFIG_DATA_ENVIRONMENT,
> -       CONFIG_COUNT_ENVIRONMENT,
>         DB_ENVIRONMENT,
>         GIT_DIR_ENVIRONMENT,
>         GIT_WORK_TREE_ENVIRONMENT,
Previous: Junio C HamanoNext: Junio C Hamano
Message 2 of 7 in “Pass or not to pass config environment down...”
  1. Junio C HamanoMar 23, 2021
  2. Jacob KellerMar 23, 2021
  3. Junio C HamanoMar 23, 2021
  4. Jacob KellerMar 23, 2021
  5. Junio C HamanoMar 23, 2021
  6. Jeff KingMar 24, 2021
  7. Patrick SteinhardtMar 31, 2021

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.