Skip to content

Filter worktree file copying through a supaignore file - #806

Merged
sbertix merged 4 commits into
mainfrom
sbertix/gh-267-granular-selection-to-copy-ignored-untra
Aug 19, 2026
Merged

Filter worktree file copying through a supaignore file#806
sbertix merged 4 commits into
mainfrom
sbertix/gh-267-granular-selection-to-copy-ignored-untra

Conversation

@sbertix

@sbertix sbertix commented Aug 19, 2026

Copy link
Copy Markdown
Collaborator

Closes #267

Summary

New worktrees can now copy only the ignored/untracked files you actually want, filtered by a supaignore file (gitignore syntax) instead of the previous all-or-nothing copy. Three layers merge, least to most specific (committed wins last): a global ~/.config/supacode/supaignore, the repo's default-worktree-directory supaignore, and a per-repo supaignore committed to the base ref (read from the object store, so it resolves before checkout). Patterns subtractively filter the existing copy-ignored / copy-untracked sets using git's own matching, isolated from the repo's .gitignore.

The copy is local-only and fail-safe: if any layer can't be resolved, nothing is copied (never a silent fallback to the unfiltered copy), surfaced as a non-fatal advisory. The settings note the local-only scope.

Type of change

  • Feature (the linked issue is a feature request marked ready)

How was this tested?

  • make check passes (format + lint)
  • make test passes
  • I built and ran the app to confirm the change works

Real-git integration tests (temp repos) cover the layered merge and precedence, gitignore isolation, negation, nested-repo pruning, the blob-only committed read, byte-preserving whitespace, and fail-safe on every read error; reducer tests cover the create-worktree wiring and coalesced advisories; unit tests cover the merge / plan / copier primitives.

Checklist

  • This pull request is linked to an issue with Closes # above.
  • For a feature, the linked issue is labeled ready.
  • I am the author of this work and accountable for it; no commit is authored or co-authored by an AI agent.
  • I have read the Contributing guide and the Code of Conduct.

Gitignore-syntax merge of the three supaignore layers (least to most specific, committed wins last), a validated resolution whose resolved case carries an EffectiveSupaignorePatterns so an empty filter is unrepresentable, a copy plan that prunes .git and nested-repo entries and dedupes across both categories by construction, and a best-effort copier that preserves symlinks, refuses a symlinked ancestor, never clobbers, and surfaces an unreadable source as a failure.
Read the three layers (global, repo-default, committed via git) and merge them, failing safe to .failed on any read error so the copy never falls back to wt's unfiltered path. Gate the committed lookup on the object being a blob and read it through a new byte-preserving ShellClient path so a pattern's edge whitespace survives (a non-UTF-8 blob fails safe). Plan the surviving ignored / untracked files with a supaignore-only matcher isolated from the repo's own .gitignore.
When a filter resolves, wt creates the worktree with both copy flags off and Supacode copies the surviving files itself; when absent, delegate to wt unchanged. A resolution or plan failure copies nothing (never the unfiltered wt copy) and a copy failure surfaces a non-fatal advisory, coalesced with the upstream-tracking advisory, never a failed creation.
Add a footer stating the copy applies to local repositories only, and disable the copy pickers with an explanation for remote repositories.
@sbertix
sbertix enabled auto-merge (squash) August 19, 2026 20:13
@sbertix
sbertix merged commit 9a33ec7 into main Aug 19, 2026
3 checks passed
@sbertix
sbertix deleted the sbertix/gh-267-granular-selection-to-copy-ignored-untra branch August 19, 2026 20:24
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.

Granular selection to copy ignored/untracked files into worktree

1 participant