From: Eric Sunshine Date: Thu, 27 Aug 2020 04:31:52 GMT Subject: Re: [PATCH] run_command: teach API users to use embedded 'args' more Message-ID: In-Reply-To: <20200827042157.GC3346457@coredump.intra.peff.net> On Thu, Aug 27, 2020 at 12:22 AM Jeff King wrote: > 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.