Replies: 1 comment 4 replies
-
Thank you for your kind words and for opening this discussion. A few quick thoughts:
Currently |
Beta Was this translation helpful? Give feedback.
4 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Very happy chezmoi user here, so thanks for this amazing tool, first of all. 🙏
After about half a year of using chezmoi, one thing I'm still struggling a bit with is how to operate chezmoi in a defensive manner. I'd like to propose a small change to address this, which would also make chezmoi's behavior more consistent in general.
In short: When
chezmoi apply
encounters a target file that it has not written previously, it should prompt in the same way as it already does if the target file has been modified since chezmoi last wrote it.Currently,
chezmoi apply
has two mechanisms against clobbering target state:--interactive
is given)The crucial issue here is that these two mechanisms are mutually exclusive: The second kind of prompt is effectively shadowed by "always prompting anyway". The downside of this is that users of
--interactive
never get to learn which of the changes they are being prompted for are very likely to be safe because the existing target file exactly matches what was previously been written by chezmoi. At the same time, they cannot drop--interactive
lest they risk clobbering target state whenever a new file is added to the source directory.Now this could be tackled from two angles:
apply --interactive
could provide more information about whether it has detected local modifications or an existing file it didn't write itselfapply
could get a more complete definition of "don't clobber stuff" by treating pre-existing files like locally modified onesI'd consider both approaches to be worthwhile improvements (independently from each other), but I'm focusing on the second one here because it would scratch my particular itch: I don't even want to use
--interactive
, I just want to be more certain thatchezmoi apply
doesn't clobber something that I couldn't later "restore" by looking at the history of my source repository. Right now,--interactive
is the only way to get this, but for every prompt I have to manually try to remember if this particular diff is simply the change I've just pulled, or if it clobbers some temporary/experimental/forgotten local modification that I just didn't yet integrate into my source repository.For the sake of completeness, I can think of one argument to be made against my suggestion: It's technically a breaking change, negating user expectations (based on past behavior, not based on intuition) that when freshly deploying chezmoi, the very first
apply
will just work, no questions asked. I personally think that has never been a good thing anyway, but I'm prepared to hear other opinions. Maybe we could to introduce a new command line flag then?I could only find one previous discussion related to this, which didn't consider the issue of pre-existing files.
I'm not a seasoned Go developer, but if my proposal resonates with you, I'm happy to give it at shot and contribute the change.
Beta Was this translation helpful? Give feedback.
All reactions