Uh oh!
There was an error while loading. Please reload this page.
fix(snapshot): seed index from the worktree's git dir - #39398
Open
Hyyy6 wants to merge 1 commit into
Open
Conversation
Hyyy6force-pushed
the
snapshot-worktree-index
branch
from
July 28, 2026 21:26
88efcb6 to
2f39e7cCompareHyyy6
commented
Jul 28, 2026
Author
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. |
Hyyy6
commented
Aug 4, 2026
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for freeto join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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