-
Notifications
You must be signed in to change notification settings - Fork 16.6k
Description
Description
Several Breeze commands fail with exit code 128 when executed from a git worktree instead of a regular clone. The root cause is that git worktrees store a .git file (not a directory) containing a gitdir: reference to an absolute host path:
gitdir: /home/user/airflow/.git/worktrees/my-worktree
Breeze mounts only the worktree directory as /opt/airflow/ inside the container. Git inside the container reads the .git file, tries to follow the gitdir: path, and fails because that absolute host path does not exist in the container filesystem.
Steps to reproduce
cd /path/to/airflow
git worktree add ../my-worktree fix/some-branch
cd ../my-worktree
breeze build-docs --docs-onlyError output
fatal: not a git repository: /home/user/airflow/.git/worktrees/my-worktree
Error 128 returned
Affected commands
Any Breeze command that calls git inside the container. Confirmed with:
breeze build-docs(callsgit config --global --add safe.directory /opt/airflowinrun_docs_build.sh)
Commands that do not use git inside the container work fine from worktrees. For example, breeze testing task-sdk-tests runs all tests successfully.
Suggested approach
Detect when AIRFLOW_ROOT_PATH/.git is a file (worktree) rather than a directory, parse the gitdir: reference, and add an extra Docker bind mount for the main repo's .git directory so git can resolve the repository inside the container.
Something like:
git_path = AIRFLOW_ROOT_PATH / ".git"
if git_path.is_file():
gitdir = git_path.read_text().strip().removeprefix("gitdir: ")
# Mount the actual .git directory from the main repo
# e.g., -v /home/user/airflow/.git:/home/user/airflow/.git:roThis would need to be applied in fix_ownership_using_docker, enter_shell, and the docker-compose volume configuration in ShellParams.
Workaround
Run the affected commands from the main clone (not the worktree) after checking out the same branch.
Use case
Contributors working on multiple PRs simultaneously benefit from worktrees to avoid constant git stash / git checkout cycles. Supporting worktrees would keep the full Breeze workflow (tests, docs, static checks) available without switching directories.