Re: Running 'git worktree add' in 'pre-commit' hook
- From
Jeff King <peff@peff.net>
- Date
- May 17, 2019, 01:19 UTC
- Message-ID
- <20190517011941.GA30372@sigill.intra.peff.net>
- In-Reply-To
- <CAPig+cQpmD9+frJWNfcts1+RFBTjrHUHk_eR4Y94GAnGZC=7hQ@mail.gmail.com>
On Thu, May 16, 2019 at 09:02:06PM -0400, Eric Sunshine wrote:
Show 15 quoted lines
> On Thu, May 16, 2019 at 8:19 PM Jeff King <peff@peff.net> wrote: > > On Thu, May 16, 2019 at 07:16:54PM -0400, Eric Sunshine wrote: > > > Is there > > > any existing code in Git for doing the relative fixups you mention for > > > other Git environment variables? > > > > You can assign local_repo_env to child_process.env (or push it > > individually to env_array if you have to mix with other variables). See > > git_connect() for an example. > > I wasn't aware of 'local_repo_env', but can see how it could be > helpful as a basis for building machinery to adjust relative paths > contained in those environment variables prior to a chdir(). My > original question was if such machinery already exists, but I'm > guessing from your response that it doesn't.
Oh, I see. I totally missed that you said "relative fixups" and not "clearing". :)
There's the chdir_notify system. Any variables which need updating need to register themselves, and then the chdir in the worktree code needs to be done with chdir_notify(). See chdir-notify.h for details.
-Peff