You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
exclude directory-shaped untracked entries from legacy snapshot staging
continue capturing ordinary untracked files in the same snapshot
add coverage for an unborn nested Git repository
Why
Git reports embedded repositories as directory entries such as tui/. Passing one with no checked-out commit to the snapshot repository's git add fails the batch and leaves the snapshot tree stale. Since ls-files --others already expands ordinary directories into files, omitting directory entries avoids the failure without losing regular file changes.
Testing
bun test test/snapshot/snapshot.test.ts
bun typecheck
bun x prettier --check src/snapshot/index.ts test/snapshot/snapshot.test.ts
AI code review — automated review for reference, author can ignore or act on any point.
Nice targeted fix. In packages/opencode/src/snapshot/index.ts (hunk @@ -257,7, changed line 260), filtering directory-shaped entries out of all before staging addresses a real failure mode: an unborn embedded repository surfaces as tui/ from ls-files --others, and a single failed git add aborts the entire batch, leaving the snapshot stale. Since the list is NUL-split (-z style output), path quoting isn't a concern, and a trailing slash cannot belong to a legitimate file, so the filter is safe when applied to both the tracked and untracked halves of the set.
Two suggestions:
Nested-repo content now disappears silently instead of failing loudly. Consider logging a one-line warning when entries are dropped (count plus names) so users can understand why nothing under tui/ ever appears in a snapshot.
In test/snapshot/snapshot.test.ts (new test, roughly lines 177–195), a sibling case with a committed nested repo would pin down intended behavior there — git add currently accepts it as a gitlink — protecting against regression if the staging strategy changes later.
Also worth a quick audit that no other call site parses status --porcelain/ls-files output into staging candidates with the same latent bug, so snapshot behavior stays consistent across entry points.
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
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.
Summary
Why
Git reports embedded repositories as directory entries such as
tui/. Passing one with no checked-out commit to the snapshot repository'sgit addfails the batch and leaves the snapshot tree stale. Sincels-files --othersalready expands ordinary directories into files, omitting directory entries avoids the failure without losing regular file changes.Testing
bun test test/snapshot/snapshot.test.tsbun typecheckbun x prettier --check src/snapshot/index.ts test/snapshot/snapshot.test.tsRequested by: @rekram1-node (Aiden via Slack)