From: Crabtree, Andrew Date: Sat, 25 Jan 2020 22:22:45 GMT Subject: RE: Inconsistent results from git rev-parse --show-toplevel Message-ID: In-Reply-To: <20200125195319.GA5519@coredump.intra.peff.net> > But the bigger thing, I think, is: who is setting GIT_DIR but not setting GIT_WORK_TREE to match? Because IMHO that's the situation that is causing the confusion. Pre-commit hook when worktrees are used? pre-commit #!/bin/bash env | grep GIT /tmp/pre_commit_test_worktree (new_branch)$ git add frob /tmp/pre_commit_test_worktree (new_branch)$ git commit -m "frob" GIT_DIR=/tmp/pre_commit_test/.git/worktrees/pre_commit_test_worktree GIT_EDITOR=: GIT_INDEX_FILE=/tmp/pre_commit_test/.git/worktrees/pre_commit_test_worktree/index GIT_PREFIX= GIT_AUTHOR_DATE=@1579990789 -0800 GIT_AUTHOR_NAME=Andrew Crabtree GIT_EXEC_PATH=/usr/local/libexec/git-core GIT_AUTHOR_EMAIL=andrew.crabtree@hpe.com [new_branch 7b1b747] frob 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 frob