fix(build): use commondir to resolve git directory in worktrees

This PR fixes git revision detection in worktrees where the worktree's
gitdir path passes through another git repository. The previous code
used `_git_find_closest_git_dir` which walks up the filesystem looking
for a `.git` entry, but this finds the wrong repository when the
worktree gitdir is stored inside another git repo (e.g. when the
project is a git submodule of a parent repo that also uses git).

Instead, read the `commondir` file that git places in every worktree's
gitdir, which directly points to the shared git object directory. Fall
back to the old filesystem walk if `commondir` doesn't exist.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 file changed