Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add an option for add to implicitly encrypt when source file is already encrypted #3142

Closed
eugenesvk opened this issue Aug 2, 2023 · 4 comments · Fixed by #3146
Closed
Labels
enhancement New feature or request

Comments

@eugenesvk
Copy link
Contributor

Is your feature request related to a problem? Please describe.

Whenever I edit files outside of chezmoi, or if those files are from GUI apps that edit those files themselves ignoring chezmoi, and I fix it by chezmoi add /fd/myfile.cfg, I get a warning message if the source file is encrypted, that adding will remove encryption. So I have to backtrack and add --encrypt, which is inconvenient

Describe the solution you'd like

Once I've added encryption this decision should be preserved until I manually remove it instead of having to confirm it every time

Describe alternatives you've considered

Using re-add, but this is a batch tool and it might override other changes in other files that I don't want to have overridden
Adding --encrypt manually or doing some shorter alias, though it doesn't completely solve the issue since I don't remember in advance that this file is encrypted

Additional context

None

@eugenesvk eugenesvk added the enhancement New feature or request label Aug 2, 2023
@halostatue halostatue changed the title Add an option for add to implicitly encrypt when source file is encrypted Add an option for add to implicitly encrypt when source file is already encrypted Aug 2, 2023
@halostatue
Copy link
Collaborator

Added "already" to title.

Would a --preserve-attributes flag be acceptable, since this is for use in a batch tool? That is chezmoi add --preserve-attributes /fd/myfile.cfg? It would be a no-op on adding new files, but when add acts like an individual-file re-add, it would automatically reuse the existing attributes.

@eugenesvk
Copy link
Contributor Author

eugenesvk commented Aug 2, 2023

I might've confused you a bit, apologies: by a batch tool I meant the re-add command itself in that it adds all the files as a single batch :) Otherwise this was me directly typing chezmoi add

A config would be preferable since then I wouldn't have to worry whether I'm calling an alias or chezmoi directly or doing something in a different shell (rare, but still)
But a flag would also work, I'll add it to my ch a alias

@twpayne
Copy link
Owner

twpayne commented Aug 2, 2023

chezmoi add has the very specific task of making the entry in the source directory match the entry in the destination directory, overwriting the entry in the source directory if needed.

chezmoi re-add is a more appropriate fit here, as it preserves the encrypted_ attribute.

#3146 extends chezmoi re-add to accept an optional list of targets, which should solve the problem here.

@eugenesvk
Copy link
Contributor Author

Thank you, I liked the simplicity of a single command as I didn't find the add/re-add distinction useful (except for mass add which could potentially be done with a add -all), but think that switching to using re-add by default should be fine

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 11, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants