[PR #8691] feat: respect GIT_DIR and GIT_WORK_TREE environment variables #12829

Open
opened 2026-02-16 18:17:43 -05:00 by yindo · 0 comments
Owner

Original Pull Request: https://github.com/anomalyco/opencode/pull/8691

State: open
Merged: No


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

**Original Pull Request:** https://github.com/anomalyco/opencode/pull/8691 **State:** open **Merged:** No --- ### 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
yindo added the pull-request label 2026-02-16 18:17:43 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#12829