Open leeavital opened 1 week ago
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).
View this failed invocation of the CLA check for more information.
For the most up to date status, view the checks section at the bottom of the pull request.
According to the issue comment, I think temporary backup + restore is preferred over editing temporary file. https://github.com/martinvonz/jj/issues/3905#issuecomment-2175297503
visudo
has to be really strict (so the system will never get broken), but we wouldn't need a guarantee of that level.
Fixes https://github.com/martinvonz/jj/issues/3905
This solves a problem where
jj config edit
drops you straight into an editor and allows you to save an invalid toml file. If you mess up your toml syntax, jj cannot launch (evenjj config edit
!)This implements a pattern I've seen in tools like
crontab -e
orvisudo
where you get dropped into a temporary file editor and the tool does a bit of sanity checking before copying over the contents of the temporary file into the actual file.Code wise: this reuses a utility function which takes care of the heavy lifting for creating a temporary file and launching an editor. I put all the validation in a new function in cli/src/config.rs, which seemed a bit like overkill but I figured the details of the config format being toml shouldn't leak into cli_util or command/config
Checklist
If applicable:
CHANGELOG.md