Skip to content

feat: respect GIT_DIR and GIT_WORK_TREE environment variables#8691

Open
KNN-07 wants to merge 1 commit intoanomalyco:devfrom
KNN-07:feat/git-dir-env-support
Open

feat: respect GIT_DIR and GIT_WORK_TREE environment variables#8691
KNN-07 wants to merge 1 commit intoanomalyco:devfrom
KNN-07:feat/git-dir-env-support

Conversation

@KNN-07
Copy link

@KNN-07 KNN-07 commented Jan 15, 2026

What does this PR do?

Add support for standard git environment variables in project detection. When GIT_DIR is set and points to a valid path, use it instead of walking up the filesystem looking for .git folder.

  • Check GIT_DIR/GIT_WORK_TREE at start of fromDirectory()
  • Derive worktree from git commands when only GIT_DIR is set
  • Fall back to filesystem walk when env vars are invalid
  • Add tests for all scenarios

How did you verify your code works?

Tests!

Closes #8694

Add support for standard git environment variables in project detection.
When GIT_DIR is set and points to a valid path, use it instead of
walking up the filesystem looking for .git folder.

- Check GIT_DIR/GIT_WORK_TREE at start of fromDirectory()
- Derive worktree from git commands when only GIT_DIR is set
- Fall back to filesystem walk when env vars are invalid
- Add tests for all scenarios
@github-actions
Copy link
Contributor

Thanks for your contribution!

This PR doesn't have a linked issue. All PRs must reference an existing issue.

Please:

  1. Open an issue describing the bug/feature (if one doesn't exist)
  2. Add Fixes #<number> or Closes #<number> to this PR description

See CONTRIBUTING.md for details.

@github-actions
Copy link
Contributor

The following comment was made by an LLM, it may be inaccurate:

No duplicate PRs found

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

OpenCode doesnt respect git env vars

1 participant

Comments