Add allowGitCommonDir support for linked Git worktrees#218
Open
goncalossilva wants to merge 2 commits into
Open
Add allowGitCommonDir support for linked Git worktrees#218goncalossilva wants to merge 2 commits into
allowGitCommonDir support for linked Git worktrees#218goncalossilva wants to merge 2 commits into
Conversation
There was a problem hiding this comment.
Pull request overview
Adds a new sandbox option to better support Git linked worktrees by optionally allowing writes to the worktree’s resolved Git common dir while keeping sensitive Git paths (hooks and config) protected.
Changes:
- Introduces
filesystem.allowGitCommonDirand wires it through the sandbox manager and both Linux (bwrap) and macOS (sandbox-exec) implementations. - Adds hardened Git directory resolution (
getGitDirs) to only grant extra access for verified linked-worktree layouts. - Expands test coverage with linked/main worktree fixtures and new integration/unit tests for common-dir behavior and config validation.
Reviewed changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| test/sandbox/wrap-with-sandbox.test.ts | Adds an integration test ensuring customConfig.filesystem.allowGitCommonDir enables writing to the Git common dir. |
| test/sandbox/mandatory-deny-paths.test.ts | Adds integration coverage for allow/deny semantics around Git common dir, config, config.worktree, hooks, and explicit denies. |
| test/sandbox/git-dirs.test.ts | New unit tests for getGitDirs main vs linked worktree resolution and hardening cases. |
| test/helpers/git-fixtures.ts | Adds reusable fixtures for main and linked worktree layouts used across tests. |
| test/config-validation.test.ts | Extends config validation fixture to include the new filesystem booleans. |
| src/sandbox/sandbox-utils.ts | Implements Git dir/common dir discovery, verification, and helper APIs to adjust allow/deny write paths. |
| src/sandbox/sandbox-manager.ts | Threads allowGitCommonDir through wrap flow and integrates common-dir allow-path resolution. |
| src/sandbox/sandbox-config.ts | Extends FilesystemConfigSchema with allowGitCommonDir. |
| src/sandbox/macos-sandbox-utils.ts | Adds allowGitCommonDir handling and injects common-dir deny paths into the seatbelt profile. |
| src/sandbox/linux-sandbox-utils.ts | Adds allowGitCommonDir handling and injects common-dir deny paths into mandatory deny resolution/bwrap binds. |
| README.md | Documents filesystem.allowGitConfig and filesystem.allowGitCommonDir. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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 free
to 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.
Improves linked worktree support in the sandbox.
In common sandbox configurations, filesystem write access is limited to the current directory. In a linked Git worktree, some Git state lives in the shared common dir outside that directory, so normal Git operations can fail. This is especially relevant for agentic development workflows, where linked worktrees and multiple parallel worktrees are common.
Support is added via
filesystem.allowGitCommonDirso sandboxed commands can write to Git’s common dir from linked worktrees.General behavior:
hooksremain blocked, and config writes still requireallowGitConfigconfig.worktreeis also blocked unlessallowGitConfigis enabledThe implementation also hardens
commondirhandling so extra write access is only granted for verified linked-worktree layouts and adds tests for config validation, linked-worktree behavior, custom-config overrides, and main-worktree behavior.