Skip to content

nebel add: encrypt already-tracked files immediately - #6

Merged
MuffinUser merged 1 commit into
mainfrom
worktree-add-encrypts-existing-files
Sep 29, 2026
Merged

MuffinUser merged 1 commit into
mainfrom
worktree-add-encrypts-existing-files

Conversation

@MuffinUser

Copy link
Copy Markdown
Owner

Summary

  • add file/add field used to only write the rule and .gitattributes line. If a matching file was already tracked and unchanged in the working tree, git kept trusting its cached stat info and never re-invoked the clean filter — the file stayed plaintext in the repository indefinitely, contradicting USER_INTERACTIONS.md's documented "no further step" promise.
  • Both subcommands now renormalize (git add --renormalize equivalent) any currently tracked file that config.MatchRule resolves to the rule just written, print what got encrypted, and warn that already-committed history is unaffected (change the underlying secret if the repo's been pushed). A brand-new glob matching nothing yet is not an error.
  • gitutil gains Renormalize (a scoped sibling of RenormalizeAll) and TrackedFiles, both using git ls-files -z/-s -z so a non-ASCII filename (which git quotes as a C-style escaped string by default) doesn't silently fall out of scope.
  • Updated spec 08 (new AC-8.11) and USER_INTERACTIONS.md § 2 to match the corrected behavior.

Test plan

  • New regression tests in cmd/nebel/add_existing_files_test.go cover: add file on an already-tracked settled file, add file with a glob matching no tracked files (must not error), add field on an already-tracked settled file, appending a field to an existing rule on an already-tracked file, and a non-ASCII filename.
  • Confirmed each new test fails on the pre-fix code and passes on the fix (manually reverted and re-ran).
  • go build ./..., go vet ./..., go test ./... -count=1 all pass.

`add file`/`add field` only wrote the rule and .gitattributes line. If a
matching file was already tracked and unchanged in the working tree, git
kept trusting its cached stat info and never re-invoked the clean
filter, so the file stayed plaintext in the repository indefinitely —
contradicting the documented "no further step" promise, and silently so
until `nebel status` was run.

Both subcommands now renormalize (git add --renormalize equivalent) any
currently tracked file that config.MatchRule resolves to the rule just
written, reporting what got encrypted and warning that already-committed
history is unaffected. Scoped to nebel's own rule matching rather than a
raw pathspec, so a brand-new glob matching nothing yet isn't an error.

gitutil gains Renormalize (RenormalizeAll's scoped sibling) and
TrackedFiles, both using `git ls-files -z`/`-s -z` so a non-ASCII
filename (which git quotes as a C-style escaped string by default)
doesn't silently fall out of scope.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@MuffinUser
MuffinUser merged commit e73fbfe into main Sep 29, 2026
6 checks passed
MuffinUser added a commit that referenced this pull request Sep 29, 2026
Re-merge PR #6 onto main (encrypt already-tracked files on add)
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.

1 participant