Web lists-archives.com

Re: Running 'git worktree add' in 'pre-commit' hook

On Thu, May 16, 2019 at 7:45 AM Duy Nguyen <pclouds@xxxxxxxxx> wrote:
> On Thu, May 16, 2019 at 6:39 PM Eric Sunshine <sunshine@xxxxxxxxxxxxxx> wrote:
> > Thinking more clearly on it, a better fix might be for git-worktree to
> > deal with this itself, converting such a path to absolute before
> > cd'ing to the new worktree directory (or something -- I don't have the
> > code in front of me to provide a more concrete suggestion).
> Our mails crossed. But yeah it's basically the same thing.
> Although I still doubt a good $GIT_INDEX_FILE would fix the problem.
> Even if you manage to create a new worktree, when you cd there and
> start using it, this $GIT_INDEX_FILE will still mess things up (unless
> you do mean to ignore the worktree's index file and update one
> provided by pre-commit hook).

I was forgetting that each worktree has its own index. Your advice
that his hook should sanitize GIT_INDEX_FILE (and possibly other GIT_*
variables) is probably the only sane approach. I don't think it's
something we can handle in some automated fashion since we don't know
whence GIT_INDEX_FILE arose.