Skip to content

Exclude .git from diff to prevent worktree breakage#47

Merged
jhrozek merged 1 commit intomainfrom
worktree-refresh
Mar 16, 2026
Merged

Exclude .git from diff to prevent worktree breakage#47
jhrozek merged 1 commit intomainfrom
worktree-refresh

Conversation

@jhrozek
Copy link
Contributor

@jhrozek jhrozek commented Mar 16, 2026

The git config sanitizer replaces the .git worktree pointer file with a .git/ directory in the snapshot. The differ then marks the original .git file as deleted, and the flusher removes it from the real workspace — breaking the worktree.

Fix by adding a DiffSecurityPatterns concept: patterns that apply only during diff/flush but not during snapshot creation. The .git pattern covers both the worktree pointer file and the .git/ directory, so nothing under .git is ever diffed or flushed back.

Also adds .git-credentials to shared security patterns.

The git config sanitizer replaces the .git worktree pointer file with
a .git/ directory in the snapshot. The differ then marks the original
.git file as deleted, and the flusher removes it from the real
workspace — breaking the worktree.

Fix by adding a DiffSecurityPatterns concept: patterns that apply only
during diff/flush but not during snapshot creation. The .git pattern
covers both the worktree pointer file and the .git/ directory, so
nothing under .git is ever diffed or flushed back.

Also adds .git-credentials to shared security patterns.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@jhrozek jhrozek merged commit 12759f2 into main Mar 16, 2026
7 checks passed
@jhrozek jhrozek deleted the worktree-refresh branch March 16, 2026 14:19
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.

2 participants