Skip to content

fix(core): skip nested repositories in snapshots - #44250

Open
opencode-agent[bot] wants to merge 1 commit into
v2from
skip-nested-repos
Open

fix(core): skip nested repositories in snapshots#44250
opencode-agent[bot] wants to merge 1 commit into
v2from
skip-nested-repos

Conversation

@opencode-agent

Copy link
Copy Markdown
Contributor

Summary

  • exclude directory-shaped untracked entries from snapshot staging
  • keep ordinary untracked files in snapshot trees
  • cover an unborn nested Git repository with a regression test

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 entire capture. With --untracked-files=all, ordinary directories are already expanded to their files, so directory entries can be omitted without losing normal file changes.

Testing

  • bun test test/git.test.ts
  • bun typecheck
  • bun x prettier --check src/git.ts test/git.test.ts

Requested by: @rekram1-node (Aiden via Slack)

@Enough1122

Copy link
Copy Markdown

AI code review — automated review for reference, author can ignore or act on any point.

Sound fix. In packages/core/src/git.ts (hunk @@ -397,7, changed line 400), filtering directory-shaped entries out of candidates before staging prevents one unborn embedded repo (tui/) from failing the whole git add batch and stalling tree capture. Since the candidate list comes from NUL-separated git output, there is no path-quoting ambiguity, and a trailing slash cannot be part of a valid file name, so the filter cannot discard legitimate entries from either the tracked or untracked half. With --untracked-files=all, ordinary directories are already expanded, so nothing else is lost.

Suggestions:

  1. The dropped entries now vanish silently. Consider logging the count/names of filtered directory entries so users can explain why a nested repo's files are absent from snapshots instead of filing "missing changes" bugs.
  2. In packages/core/test/git.test.ts (new test, roughly lines 134–161), a companion case with a committed nested repo would document current behavior (git add records it as a gitlink) and guard the invariant if staging logic evolves.
  3. Worth confirming no sibling code path builds staging candidates without this filter, so all snapshot entry points behave identically.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants