Validate linked worktrees before inheriting project trust (#39616)

## Why

A checkout could point its `.git` file at a trusted repository's worktree
directory without proving that the repository had registered that checkout.
This could cause project configuration from an unrelated checkout to be treated
as trusted.

## What changed

- Verify the linked worktree's `gitdir` backlink, `commondir`, registered
  checkout, and main checkout ownership before resolving the main repository's
  trust key.
- Reject missing, oversized, symlinked, mismatched, or swapped Git metadata.
- Preserve valid linked worktrees that use path aliases, separate Git
  directories, or non-UTF-8 POSIX paths.

## Testing

Add resolver and config-loading coverage for forged worktrees, metadata races,
case-sensitive paths, moved worktrees, and host MCP startup from project config.

GitOrigin-RevId: 6052a7d10ad2d613436f20175c356abdef8c758e
This commit is contained in:
Jeremy Rose authored and copyberry committed 2026-08-20 06:29:32 +00:00
1 parent 250b5ea2bf
commit bc3545b805
12 files changed
+859 -80

No files matched your search

+1
View File
@@ -24,6 +24,7 @@ use url::Url;
mod absolute_path_normalization;
mod api_path_string;
mod native_path_bytes;
use absolute_path_normalization::path_uri_from_segments;