Web lists-archives.com

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

On Thu, May 16, 2019 at 7:33 AM Eric Sunshine <sunshine@xxxxxxxxxxxxxx> wrote:
> I researched this also and concluded that it's a bug in git-commit.
> You run afoul of it in other situations, as well. For instance, say
> you have your index file in a non-standard location:
>     $ export GIT_INDEX_FILE=../storage/index
>     $ git worktree add --detach other
>     Preparing worktree (detached HEAD c9156d2)
>     fatal: Unable to create '/.../foo/other/../storage/index.lock': No
> such file or directory
>     $
> I think the correct fix is for git-commit to assign GIT_INDEX_FILE
> with the absolute path to the index file, not a relative path.

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).