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

Temporarily ignore changes in the local file until it changes again #4152

Open
eugenesvk opened this issue Dec 21, 2024 · 3 comments
Open

Temporarily ignore changes in the local file until it changes again #4152

eugenesvk opened this issue Dec 21, 2024 · 3 comments
Labels
enhancement New feature or request

Comments

@eugenesvk
Copy link
Contributor

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

Situation: I've made a bunch of (sometimes incompatible) changes to both source and destination files and is in the process of reconciliation with chezmoi apply -v --interactive

  1. The first file: ok, I've added a few temporary changes and don't want to overwrite them, so I press n
  2. next file: hm, don't remember these changes, so I quit chezmoi and do manual reconciliation, see diff in a better app, see the change history etc.
  3. Ok, I restart the apply process: now the first file appears again and I have to ignore it again

And with many iterations of step 2 this becomes a bit tedious - and also risks a mistaken y overwrite on a file you wanted to skip

Describe the solution you'd like

Add an extra ignore command that will remember the modified times of the source/target files and unless any of those change won't suggest them again

Describe alternatives you've considered

Counting the number of ignored files to quickly press n # of times
Or sometimes I manually add a target path to the apply command to skip them, but then I have to do that for a few paths, so also a bit inconvenient (though chezmoi status helps generating a list)

Additional context

N/a

@eugenesvk eugenesvk added the enhancement New feature or request label Dec 21, 2024
@twpayne
Copy link
Owner

twpayne commented Dec 24, 2024

This is an interesting idea, and I see the value and reasoning behind it.

I'm concerned that adding this ability will add hard-to-discover state which will lead to confusing behavior later. Specifically, if you tell chezmoi to ignore the file with its current contents, forget that you did this, and later try to update the file then it'll be confusing that chezmoi is skipping the file.

Instead, I'd recommend do this manually in your .chezmoiignore file, for example:

{{/* If .zshrc is known to be out of sync, then ignore it */}}
{{ if eq (joinPath .chezmoi.homeDir ".zshrc" | include | sha256sum) "a2a01e0ce4e34ff0975ce8a6fc5dc83901b1917ca5a87df502ce47e50e2df03d" }}
.zshrc
{{ end }}

@eugenesvk
Copy link
Contributor Author

The forgetfulness could be countered by forgetfulness :) - chezmoi could ony keep the ignore list for some X minutes (along with having a chezmoi forget command)

Otherwise your workaround seems rather cumbersome to add to many templates, and is also subject to forgetfulness - trying to remember the need to add this workaround the next time you enconter the issue instead of having a helpful selection option right there when you need it

@halostatue
Copy link
Collaborator

chezmoi forget already exists, but it removes the target file from the chezmoi state permanently (this is different than chezmoi destroy).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants