[PR #7517] fix(opencode): resolve git worktree .git files #12426

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

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

State: open
Merged: No


What does this PR do?

  • Read .git files and follow gitdir: references to actual git directory
  • Handles both absolute and relative paths
  • Falls back gracefully when target doesn't exist

Why?

Git worktrees create a .git file (not directory) containing a path to the actual git directory. Without following this reference, the code fails to store the cached ID, which slows down subsequent startups.

How did you verify your code works?

  • Added test for absolute gitdir path resolution
  • Added test for relative gitdir path resolution
  • Added test for non-existent target fallback
  • Tested opening in a worktree, a normal git checkout, and outside of git
**Original Pull Request:** https://github.com/anomalyco/opencode/pull/7517 **State:** open **Merged:** No --- ### What does this PR do? - Read .git files and follow `gitdir:` references to actual git directory - Handles both absolute and relative paths - Falls back gracefully when target doesn't exist ### Why? Git worktrees create a `.git` file (not directory) containing a path to the actual git directory. Without following this reference, the code fails to store the cached ID, which slows down subsequent startups. ### How did you verify your code works? - Added test for absolute gitdir path resolution - Added test for relative gitdir path resolution - Added test for non-existent target fallback - Tested opening in a worktree, a normal git checkout, and outside of git
yindo added the pull-request label 2026-02-16 18:17:20 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#12426