◐ Shell
clean mode source ↗

Adjust git dir when checking for merge in worktree by errsyn · Pull Request #662 · pre-commit/pre-commit-hooks

Fixes #638

Right now ongoing merges aren't detected in linked working trees, as it is assumed that .git is a directory. However, this is not the case for linked working trees. Working trees instead have a .git file, which references the path to the git directory like this:

$ cat .git
gitdir: /path/to/main-working-tree/.git/worktrees/<worktree-name>

So when we are dealing with a linked working tree, we just have to readjust the git directory to the one referenced in the .git file.