Re: [PATCH] run_command: teach API users to use embedded 'args' more
- From
Eric Sunshine <sunshine@sunshineco.com>
- Date
- Aug 27, 2020, 04:31 UTC
- Message-ID
- <CAPig+cS1uMw6YDVjzb8FbBmC=iVjged-wHu0LF2+trmW-4ZfVw@mail.gmail.com>
- In-Reply-To
- <20200827042157.GC3346457@coredump.intra.peff.net>
On Thu, Aug 27, 2020 at 12:22 AM Jeff King <peff@peff.net> wrote:
Show 5 quoted lines
> I've actually considered dropping child_process.argv entirely. Having > two separate ways to do the same thing gives the potential for > confusion. [...] > > Likewise for child_process.env_array.
builtin/worktree.c:add_worktree() is a case in which an environment strvec is built once and re-used for multiple run_command() invocations by re-assigning it to child_process.env before each run_command(). It uses child_process.env rather than child_process.env_array because run_command() clears child_process.env_array upon completion, which makes it difficult to reuse a prepared environment strvec repeatedly.
Nevertheless, that isn't much of a reason to keep child_process.env. Refactoring add_worktree() a bit to rebuild the environment strvec on-demand wouldn't be very difficult.