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

Re: [PATCH] trace2: teach Git to log environment variables

From
Junio C Hamano <gitster@pobox.com>
Date
Mar 20, 2020, 21:21 UTC
Message-ID
<xmqqimiybu3r.fsf@gitster.c.googlers.com>
In-Reply-To
<0f5607a4242cc7b61ad36d0782c9d1250c4d4d7d.1584737973.git.steadmon@google.com>
Josh Steadmon <steadmon@google.com> writes:
Show 8 quoted lines
> +trace2.envVars::
> +	A comma-separated list of "important" environment variables that should
> +	be recorded in the trace2 output.  For example,
> +	`GIT_HTTP_USER_AGENT,GIT_CONFIG` would cause the trace2 output to
> +	contain events listing the overrides for HTTP user agent and the
> +	location of the Git configuration file (assuming any are set).  May be
> +	overriden by the `GIT_TRACE2_ENV_VARS` environment variable.  Unset by
> +	default.
In other words, by default nothing is logged?
>  		trace2_cmd_alias(alias_command, new_argv);
>  		trace2_cmd_list_config();
> +		trace2_cmd_list_env_vars();

OK, so we treat the settings of configuration variables and environment variables pretty much the same. Both affect how git behaves for the end-users, and even though they are physically different mechanisms, philosophically the reason they are worth logging are the same for these two categories.

Show 5 quoted lines
> @@ -439,6 +441,7 @@ static int run_builtin(struct cmd_struct *p, int argc, const char **argv)
>  	trace_argv_printf(argv, "trace: built-in: git");
>  	trace2_cmd_name(p->cmd);
>  	trace2_cmd_list_config();
> +	trace2_cmd_list_env_vars();
Likewise.  That is why these two appear together.
>  			trace2_cmd_name(cmds[i].name);
>  			trace2_cmd_list_config();
> +			trace2_cmd_list_env_vars();
And here.
Show 13 quoted lines
> diff --git a/trace2/tr2_sysenv.c b/trace2/tr2_sysenv.c
> index 3c3792eca2..a380dcf910 100644
> --- a/trace2/tr2_sysenv.c
> +++ b/trace2/tr2_sysenv.c
> @@ -29,6 +29,8 @@ struct tr2_sysenv_entry {
>  static struct tr2_sysenv_entry tr2_sysenv_settings[] = {
>  	[TR2_SYSENV_CFG_PARAM]     = { "GIT_TRACE2_CONFIG_PARAMS",
>  				       "trace2.configparams" },
> +	[TR2_SYSENV_ENV_VARS]      = { "GIT_TRACE2_ENV_VARS",
> +				       "trace2.envvars" },
>  
>  	[TR2_SYSENV_DST_DEBUG]     = { "GIT_TRACE2_DST_DEBUG",
>  				       "trace2.destinationdebug" },

In this array, similar things are grouped together and groups are separated by a blank line in between. As the new ENV_VARS are treated pretty much the same way as CFG_PARAM, it is thrown in the same group, instead of becoming a group on its own. Makes sense.

Show 11 quoted lines
> diff --git a/trace2/tr2_sysenv.h b/trace2/tr2_sysenv.h
> index d4364a7b85..3292ee15bc 100644
> --- a/trace2/tr2_sysenv.h
> +++ b/trace2/tr2_sysenv.h
> @@ -11,6 +11,7 @@
>   */
>  enum tr2_sysenv_variable {
>  	TR2_SYSENV_CFG_PARAM = 0,
> +	TR2_SYSENV_ENV_VARS,
>  
>  	TR2_SYSENV_DST_DEBUG,
Likewise.
Thanks.
Previous: Josh SteadmonNext: Jeff Hostetler
Message 2 of 4 in “trace2: teach Git to log environment variables”
  1. trace2: teach Git to log environment variablesJosh Steadmon, Mar 20, 2020
  2. Junio C HamanoMar 20, 2020
  3. Jeff HostetlerMar 23, 2020
  4. Junio C HamanoMar 23, 2020

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.