fix(snapshot): seed index from the worktree's git dir - #39398
Conversation
88efcb6 to
2f39e7c
Compare
|
test, typecheck, and nix-eval are queued behind the first-time fork contributor approval gate. Everything else is green. I've already run bun typecheck and bun test test/snapshot/snapshot.test.ts locally in packages/opencode (55 pass, 1 skip, 0 fail) — happy to re-run anything once workflows are approved. |
|
Automated PR Cleanup Thank you for contributing to opencode. Due to the high volume of PRs from users and AI agents, we periodically close older PRs using automated criteria so maintainers can focus review time on the most active and community-supported contributions. This PR was closed because it matched the following cleanup criteria:
PRs created within the last month are not affected by this cleanup. If you believe this PR was closed incorrectly, or if you are still actively working on it, please leave a comment explaining why it should be reopened. A maintainer can review and reopen it if appropriate. Thanks again for taking the time to contribute. |
Issue for this PR
Closes #39388
Type of change
What does this PR do?
#31798 seeds the snapshot repo with the source repo's git index so
git add --allreuses already-hashed entries instead of re-hashing the whole tree. In a linked worktree
--git-common-dirresolves to the main repository's.git, so the copied index is themain repo's, which does not match the worktree's working tree.
git add --allthenre-hashes every file, reintroducing the hang on large worktrees.
Resolve the index from
--git-dir(cwd = the worktree) instead, which in a linked worktreepoints at the worktree's own
.git/worktrees/<name>(whose index matches its working tree).Falls back to the common dir's index when
rev-parsefails, preserving the existingbest-effort behavior.
How did you verify your code works?
End-to-end (
opencode run "say hi"in a chromium--depth 1worktree, ~500k files):git add --allre-hashingIsolated git-level reproduction (replicating
Snapshot.seed()atpackages/opencode/src/snapshot/index.ts:198-239):4b825dc6...(empty)36e0ef8a...36e0ef8a...B and C produce identical tree hashes — the fix preserves correctness. C is 27x faster.
bun test test/snapshot/snapshot.test.tsfrompackages/opencode— 55 pass, 1 skip, 0 fail.bun typecheckfrompackages/opencode— clean.Screenshots / recordings
Not a UI change.
Checklist