Skip to content

fix(snapshot): skip nested repositories without a commit - #63897

Open
Nowaker wants to merge 1 commit into
anomalyco:v1from
Nowaker:snapshot-unborn-upstream
Open

Nowaker wants to merge 1 commit into
anomalyco:v1from
Nowaker:snapshot-unborn-upstream

Conversation

@Nowaker

@Nowaker Nowaker commented Nov 14, 2026

Copy link
Copy Markdown

Issue for this PR

Fixes the snapshot failure reported in #23105.

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

The snapshot store records an untracked nested repository as a gitlink to its HEAD. When that repository's branch has no commit yet, git add cannot record the gitlink and fails the whole batch:

error: 'tui/' does not have a commit checked out
error: unable to index file 'tui/'
fatal: adding files failed

Every later snapshot in that project fails the same way, so the session gets no diffs, patches or reverts until the nested repository gets a commit.

add() now checks each candidate directory that holds a .git entry with git --git-dir <dir>/.git rev-parse --verify --quiet HEAD and leaves out only the ones without a HEAD. Nested repositories with a commit are still recorded as gitlinks, and ordinary directories are untouched. The explicit --git-dir keeps git from climbing into the parent repository and skips the safe.directory ownership check.

#44259 and #44250 skipped every directory entry instead, which also drops the gitlinks of nested repositories that do have commits.

How did you verify your code works?

From packages/opencode:

  • bun run test test/snapshot/snapshot.test.ts - 56 pass, 1 skip, 0 fail. The new test "nested repository without a commit does not block the snapshot" creates a nested repository with no commit, then a nested repository with a commit and a modified tracked file. It asserts that the patch lists the modified file and the committed repository's gitlink and nothing under the empty one. Without the source change the patch is empty and the test fails.
  • bun typecheck - passed. Prettier is clean on both files.

Screenshots / recordings

Not a UI change.

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

This PR is AI generated, but under direct supervision and on request of @Nowaker.

--body-file <(awk '/^<!-- BEGIN PR BODY -->$/{body=1;next}/^<!-- END PR BODY -->$/{exit}body' /home/nowaker/projekty/webapps/opencode/.vibeterm/forklog/pr-queue/06-snapshot-unborn.md)

)


A nested repository is staged into the snapshot store as a gitlink to
its HEAD. When its branch has no commit yet, git add cannot record the
gitlink and fails the whole batch ("'<dir>/' does not have a commit
checked out ... fatal: adding files failed"), so every snapshot in that
project stays stale: no session diffs, patches or reverts.

add() now checks each candidate directory that holds a .git entry with
`git --git-dir <dir>/.git rev-parse --verify --quiet HEAD` and leaves
out the ones without a HEAD until their first commit. Nested
repositories with a commit are still recorded as gitlinks, and plain
directories are untouched, since only paths with their own .git are
checked. An explicit --git-dir avoids discovery climbing into the
parent repository and the safe.directory ownership check.

Fixes the failure reported in anomalyco#23105. The earlier attempts anomalyco#44259 and
anomalyco#44250 skipped every directory entry, which also drops the gitlinks of
nested repositories that do have commits.

AI-Model: anthropic/claude-opus-5-5
AI-Variant: high
AI-Tool: opencode 1.19.5-vt-464-006d837c50
AI-Platform: linux
AI-Harness: Vibeterm df0af2c9bb7
AI-Session-ID: ses_e284adde6ffe1ycvQIhjknnH3s
Nowaker added a commit to Nowaker/opencode that referenced this pull request Nov 17, 2026
Add pr-queue/00-open-slots.md as the daily drain's record of the three
open author PRs (anomalyco#63062, anomalyco#63063, anomalyco#63897), their checks, next nudges and
a log of every nudge, starting with the 2026-11-17 pings on anomalyco#63062 and
anomalyco#63063. Mark entry 06 filed as anomalyco#63897; it still read "not filed" after
anomalyco#54578 closed and freed its slot. The cap stays full and entry 10 is
next in line.

AI-Model: anthropic/claude-opus-5-5
AI-Variant: high
AI-Tool: opencode 1.18.34-vt-101-907b3bc518
AI-Platform: linux
AI-Harness: Vibeterm 3c3f1fadd21
AI-Session-ID: ses_eeda1d251ffel81U5Y42j4kb33

This branch has not been deployed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant