Description
When using a bare repository layout, repo_path may resolve differently depending on whether wt is invoked directly or via a Git alias.
This seems related to Git injecting environment variables such as GIT_DIR when executing shell aliases (alias = "!cmd"). This variables influence the behavior of internal git commands used by worktrunk.
Context
Repository layout (bare layout)
repo/
.git/ # bare repository
main/ # worktree
Configure a simple alias in worktrunk for reproduction:
[aliases]
echo = "echo {{repo_path}}"
Also configure a Git alias:
git config --global alias.wt '!wt'
Result:
$ cd /path/to/repo
$ wt step echo
◎ Running alias echo
/path/to/repo/.git
$ git wt step echo
◎ Running alias echo
/path/to/repo # → not `/path/to/repo/.git`
Additional observations
Debug logs show the following when the issue occurs:
$ git rev-parse --is-bare-repository [.git]
[wt-trace] context=.git cmd="git rev-parse --is-bare-repository"
fatal: not a git repository: '.git'
This appears to happen when GIT_DIR is present in the environment.
For example:
cd repo/.git
git rev-parse --is-bare-repository
# → true
GIT_DIR=.git git rev-parse --is-bare-repository
# → fatal: not a git repository: '.git'
This suggests that when GIT_DIR is set to .git, Git resolves it relative to the current directory (repo/.git/.git), causing the failure.
Since Git sets GIT_DIR when running shell aliases (git <alias>), this may explain why git wt ... behaves differently from invoking wt directly.
Versions
- wt: 0.34.1
- git: 2.50.1 (Apple Git-155)
Description
When using a bare repository layout,
repo_pathmay resolve differently depending on whetherwtis invoked directly or via a Git alias.This seems related to Git injecting environment variables such as
GIT_DIRwhen executing shell aliases (alias = "!cmd"). This variables influence the behavior of internalgitcommands used by worktrunk.Context
Repository layout (bare layout)
Configure a simple alias in
worktrunkfor reproduction:Also configure a Git alias:
Result:
Additional observations
Debug logs show the following when the issue occurs:
This appears to happen when
GIT_DIRis present in the environment.For example:
This suggests that when
GIT_DIRis set to.git, Git resolves it relative to the current directory (repo/.git/.git), causing the failure.Since Git sets
GIT_DIRwhen running shell aliases (git <alias>), this may explain whygit wt ...behaves differently from invokingwtdirectly.Versions