fix(project): use git common dir for bare repo project cache#19054
fix(project): use git common dir for bare repo project cache#19054StevenTCramer wants to merge 2 commits intoanomalyco:devfrom
Conversation
|
The following comment was made by an LLM, it may be inaccurate: Based on my search, I found one potentially related PR that might be addressing similar concerns: Related PR:
This PR appears related because it also deals with project IDs across worktrees, which is the same domain as the current PR. However, this is likely a different fix addressing a different aspect of the worktree/project identity issue. No exact duplicate PRs found addressing the same bare repo cache placement issue described in PR #19054. |
|
Thanks for updating your PR! It now meets our contributing guidelines. 👍 |
fafcb9a to
5fc5fbc
Compare
|
I think a better fix is to focus on the I would improve this line: Is there a way to detect a bare repo? I would try to detect that, and just keep worktree pointed at the bare repo itself if so |
|
Good point on fixing the Regarding bare repo detection: I considered using const commonName = pathSvc.basename(common)
const isBareRepo = commonName.endsWith(".git") && commonName !== ".git"This avoids spawning an extra git process (~50-100ms overhead) in a hot path. The heuristic correctly identifies bare repos (e.g., |
725c405 to
d462551
Compare
|
The @jlongster This is a pre-existing flaky E2E test, not a regression from this change. |
d462551 to
d462603
Compare
Use git-common-dir as the project ID cache location so bare-repo-backed worktrees do not write to a shared parent .git path. Add regression tests that reproduce parent-path cache collisions across bare repos.
Detect bare repos by checking if git-common-dir basename ends with .git (excluding .git itself). This ensures both the worktree field in the database and the cache location are correct for bare-repo-backed worktrees.
d462603 to
ce91176
Compare
Issue for this PR
Closes #18045
Type of change
What does this PR do?
This fixes project ID cache placement for bare-repo-backed worktrees.
Before this change, cache read/write used
worktree/.git/opencode. In bare repo setups,worktreeresolves to the parent of the bare repo, so cache could be written to a shared parent path like<parent>/.git/opencode.This PR reads and writes cache at
git rev-parse --git-common-dir(common/opencode) instead. That is the correct git metadata location for normal repos, worktrees, and bare repos.I also added regression tests for:
<bare>.git/opencode, not parent)How did you verify your code works?
bun test --timeout 30000 test/project/inpackages/opencode.git/opencodepathScreenshots / recordings
N/A (no UI changes)
Checklist