From: Junio C Hamano Date: Fri, 12 Jan 2018 19:19:44 GMT Subject: Re: [PATCH v3 4/4] trace.c: be smart about what env to print in trace_run_command() Message-ID: In-Reply-To: <20180112184546.GA15514@sigill.intra.peff.net> Jeff King writes: > The actual prep_childenv() code looks like it would always do > last-one-wins, so we should treat FOO as unset in that final case. But > that only kicks in on non-Windows. > > On Windows we feed cmd->env straight to mingw_spawnvpe(). That ends up > in make_environment_block(), which looks like it does something similar. > > It's too bad the prep code is not shared, since then we could probably > just ask _it_ which deltas it applied. Yeah, but that function does a lot more than computing delta. It's primary point, which comes from ae25394b ("run-command: prepare child environment before forking", 2017-04-19), is to create a full copy of the environment, not just a series of putenv/unsetenv that describes what gets changed, and that is done to avoid any allocation after fork before exec in the child process. I guess prep_childenv() could take an extra and optional string-list to report what "deltas" it applied to the tracing machinery. I am not sure if that is worth it, though.