ok/jj
1
0
Fork 0
forked from mirrors/jj

feat(diff): add ui.diff-instructions option to suppress JJ-INSTRUCTIONS file

This commit is contained in:
Waleed Khan 2023-06-06 21:33:32 -05:00
parent 8f9d72c028
commit 74b846870c
4 changed files with 16 additions and 1 deletions

View file

@ -291,6 +291,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
configured by `template-aliases.<name> = <expression>`. Be aware that
the template syntax isn't documented yet and is likely to change.
* The `ui.diff-instructions` config setting can be set to `false` to inhibit the
creation of the `JJ-INSTRUCTIONS` file as part of diff editing.
### Fixed bugs
* When sharing the working copy with a Git repo, we used to forget to export

View file

@ -327,6 +327,13 @@ merge-tools.kdiff3.edit-args = [
"--merge", "--cs", "CreateBakFiles=0", "$left", "$right"]
```
### `JJ-INSTRUCTIONS`
When editing a diff, jj will include a synthetic file called `JJ-INSTRUCTIONS`
in the diff with instructions on how to edit the diff. Any changes you make to
this file will be ignored. To suppress the creation of this file, set
`ui.diff-instructions = false`.
### Using Vim as a diff editor
Using `ui.diff-editor = "vimdiff"` is possible but not recommended. For a better

View file

@ -162,6 +162,10 @@ impl UserSettings {
.unwrap_or(false)
}
pub fn diff_instructions(&self) -> bool {
self.config.get_bool("ui.diff-instructions").unwrap_or(true)
}
pub fn config(&self) -> &config::Config {
&self.config
}

View file

@ -345,7 +345,8 @@ pub fn edit_diff(
let instructions_path = right_wc_dir.join("JJ-INSTRUCTIONS");
// In the unlikely event that the file already exists, then the user will simply
// not get any instructions.
let add_instructions = !instructions.is_empty() && !instructions_path.exists();
let add_instructions =
settings.diff_instructions() && !instructions.is_empty() && !instructions_path.exists();
if add_instructions {
// TODO: This can be replaced with std::fs::write. Is this used in other places
// as well?