andreahlert opened a new issue, #62881:
URL: https://github.com/apache/airflow/issues/62881
### 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
```bash
cd /path/to/airflow
git worktree add ../my-worktree fix/some-branch
cd ../my-worktree
breeze build-docs --docs-only
```
### Error 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` (calls `git config --global --add safe.directory
/opt/airflow` in `run_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:
```python
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:ro
```
This 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.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]