Skip to content

feat(server): copy .worktreeinclude files into new worktrees - #7956

Open
Sriram-52 wants to merge 7 commits into
pingdotgg:mainfrom
Sriram-52:feat/worktreeinclude
Open

feat(server): copy .worktreeinclude files into new worktrees#7956
Sriram-52 wants to merge 7 commits into
pingdotgg:mainfrom
Sriram-52:feat/worktreeinclude

Conversation

@Sriram-52

@Sriram-52 Sriram-52 commented Aug 23, 2026

Copy link
Copy Markdown

New worktrees start with tracked files only, so untracked local files like .env never make it across; today every repo has to hand-roll that copy in its setup script. This adds support for a repo-root .worktreeinclude file (same convention as Claude Code): gitignore-style patterns of untracked files to copy into each newly created worktree.

The copy runs in the VCS driver's createWorktree, right after git worktree add, so all three creation paths get it (thread bootstrap, PR threads, and the mobile vcs.createWorktree RPC) and it completes before the project setup script launches. Git does the pattern matching itself via git ls-files --others --ignored --exclude-from, so semantics are exactly gitignore's with no matcher code of our own. Copying is best-effort: a failed copy logs a warning and never blocks worktree creation.

Includes driver tests against real git (pattern matching incl. nested files and directory patterns, plus the failure path) and a user doc at docs/user/worktrees.md.

Built with Claude Fable 5 on Claude Code.

🤖 Generated with Claude Code


Note

Medium Risk
Adds filesystem copies of typically-secret untracked files into new worktrees, with symlink-escape checks and best-effort error swallowing. A bug in containment or matching could leak files outside the worktree or skip intended copies.

Overview
New worktrees now copy untracked files matching a repo-root .worktreeinclude (gitignore-style patterns, typically .env and similar) from the source checkout into the new tree, right after git worktree add and before setup scripts.

Git does the matching via ls-files --others --ignored --exclude-from. Copies are best-effort: failures and oversized listings log warnings and never roll back worktree creation. Checked-out tracked files win on collisions; writes through tracked symlinks are skipped. Relative worktree paths are resolved against cwd so the copy target matches git.

User docs live in docs/user/worktrees.md.

Reviewed by Cursor Bugbot for commit ed8a86b. Bugbot is set up for automated code reviews on this repo. Configure here.

Note

Copy .worktreeinclude-matched untracked files into new worktrees

  • Adds copyWorktreeIncludedFiles to GitVcsDriverCore, which lists untracked files matching a repo-root .worktreeinclude via git ls-files --others --ignored --exclude-from (60s timeout) and best-effort copies them into the newly created worktree.
  • Checked-out tracked files take precedence over copies on collisions; symlink traversal is avoided by checking target paths and resolving deepest ancestors within the worktree real path.
  • createWorktree now resolves relative worktree paths against cwd so worktree.path is absolute and matches git behavior; copy failures are logged without failing worktree creation.
  • Adds user docs at worktrees.md and updates the glossary and README index.
  • Risk: per-entry copy failures are swallowed (only logged); a truncated ls-files output results in a partial copy with a warning, so users should verify .worktreeinclude results in GitVcsDriverCore.ts.

Macroscope summarized ed8a86b.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Aug 23, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: a1f3b1b4-4716-46a4-b01b-e5b348001083

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions github-actions Bot added vouch:unvouched PR author is not yet trusted in the VOUCHED list. size:M 30-99 changed lines (additions + deletions). labels Aug 23, 2026
Comment thread apps/server/src/vcs/GitVcsDriverCore.ts
Comment thread apps/server/src/vcs/GitVcsDriverCore.ts Outdated
…on-tolerant

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Comment thread apps/server/src/vcs/GitVcsDriverCore.ts Outdated
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@github-actions github-actions Bot added size:L 100-499 changed lines (additions + deletions). and removed size:M 30-99 changed lines (additions + deletions). labels Aug 23, 2026
Comment thread apps/server/src/vcs/GitVcsDriverCore.ts
@macroscopeapp

macroscopeapp Bot commented Aug 23, 2026

Copy link
Copy Markdown
Contributor

Approvability

Verdict: Skipped

Macroscope did not run approvability analysis for this PR. Macroscope could not determine whether this PR modifies its approvability configuration, so the PR was not approved automatically. A PR that may change the rules that govern approval is never approved automatically.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Comment thread apps/server/src/vcs/GitVcsDriverCore.ts
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

@cursor cursor Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 71252d5. Configure here.

Comment thread apps/server/src/vcs/GitVcsDriverCore.ts
…tories

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Comment thread apps/server/src/vcs/GitVcsDriverCore.ts
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:L 100-499 changed lines (additions + deletions). vouch:unvouched PR author is not yet trusted in the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant