Re: [PATCH 2/2] worktree: add: change to new worktree directory before running hook
- From
Eric Sunshine <sunshine@sunshineco.com>
- Date
- Feb 13, 2018, 04:48 UTC
- Message-ID
- <CAPig+cT+SkmFKBFc3rbh7SMk10dU8E-y4s+WR10GPNtGk+7S7g@mail.gmail.com>
- In-Reply-To
- <CAPig+cTLQ6h+stLLns-837hP0nNOpE3vwu8_ZeO2GoAaDs7buw@mail.gmail.com>
On Mon, Feb 12, 2018 at 11:42 PM, Eric Sunshine <sunshine@sunshineco.com> wrote:
Show 6 quoted lines
> So, either approach works: removing GIT_DIR or using "worktree add"'s > existing GIT_DIR and GIT_WORK_TREE. I favor the latter since it is > consistent with how "worktree add" invokes other command already and, > especially, because it also addresses the issue Junio raised of > user-defined GIT_DIR/GIT_WORK_TREE potentially polluting the hook's > environment.
Just to be clear: Regardless of which fix is used, we still want to chdir() to the new worktree to guarantee that the directory in which the 'post-checkout' hook is run is predictable.
In the re-roll, I'm going with the latter approach of re-using builtin/worktree.c's existing GIT_DIR/GIT_WORK_TREE which it already exports to other commands it invokes.