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

expand $left/$right in edit-args, replace all $variable matches #1211

Merged
merged 6 commits into from
Feb 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
* The `diff.format` config option is now called `ui.diff.format`. The old name
is still supported for now.

* `merge-tools.<name>.edit-args` now requires `$left`/`$right` parameters.
The default is `edit-args = ["$left", "$right"]`.

### New features

* The default log format now uses the committer timestamp instead of the author
Expand Down
24 changes: 17 additions & 7 deletions docs/config.md
Original file line number Diff line number Diff line change
Expand Up @@ -199,21 +199,31 @@ Obviously, you would only set one line, don't copy them all in!
## Editing diffs

The `ui.diff-editor` setting affects the tool used for editing diffs (e.g.
`jj split`, `jj amend -i`). The default is `meld`. The left and right
directories to diff are passed as the first and second argument respectively.
`jj split`, `jj amend -i`). The default is `meld`.

`jj` makes the following substitutions:

- `$left` and `$right` are replaced with the paths to the left and right
directories to diff respectively.

If no arguments are specified, `["$left", "$right"]` are set by default.

For example:

```toml
ui.diff-editor = "kdiff3" # Use merge-tools.kdiff3.edit-args
ui.diff-editor = ["kdiff3", "--merge"] # Specify edit-args inline
# Use merge-tools.kdiff3.edit-args
ui.diff-editor = "kdiff3"
# Specify edit-args inline
ui.diff-editor = ["kdiff3", "--merge", "$left", "$right"]
```

Custom arguments can be added, and will be inserted before the paths to diff:
yuja marked this conversation as resolved.
Show resolved Hide resolved
If `ui.diff-editor` consists of a single word, e.g. `"kdiff3"`, the arguments
will be read from the following config keys.

```toml
# merge-tools.kdiff3.program = "kdiff3" # Defaults to the name of the tool if not specified
merge-tools.kdiff3.edit-args = ["--merge", "--cs", "CreateBakFiles=0"]
merge-tools.kdiff3.edit-args = [
"--merge", "--cs", "CreateBakFiles=0", "$left", "$right"]
yuja marked this conversation as resolved.
Show resolved Hide resolved
```

yuja marked this conversation as resolved.
Show resolved Hide resolved
### Using Vim as a diff editor
Expand Down Expand Up @@ -260,7 +270,7 @@ merge-tools.vimdiff.program = "vim"
merge-tools.vimdiff.merge-tool-edits-conflict-markers = true # See below for an explanation
```

`jj` replaces the following arguments with the appropriate file names:
`jj` makes the following substitutions:

- `$output` (REQUIRED) is replaced with the name of the file that the merge tool
should output. `jj` will read this file after the merge tool exits.
Expand Down
6 changes: 6 additions & 0 deletions src/config-schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,12 @@
"program": {
"type": "string"
},
"edit-args": {
"type": "array",
"items": {
"type": "string"
}
},
"merge-args": {
"type": "array",
"items": {
Expand Down
5 changes: 3 additions & 2 deletions src/config/merge_tools.toml
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
[merge-tools.kdiff3]
# --merge to open output pane, CreateBakFiles=0 to not include backup files in commit
edit-args = ["--merge", "--cs", "CreateBakFiles=0"]
edit-args = ["--merge", "--cs", "CreateBakFiles=0", "$left", "$right"]
merge-args = ["$base", "$left", "$right", "-o", "$output", "--auto"]

[merge-tools.meld]
edit-args = ["$left", "$right"]
merge-args = ["$left", "$base", "$right", "-o", "$output", "--auto-merge"]

[merge-tools.vimdiff]
Expand All @@ -16,4 +17,4 @@ merge-tool-edits-conflict-markers = true
# Using vimdiff as a diff editor is not recommended. For instructions on configuring
# the DirDiff Vim plugin for a better experience, see
# https://gist.github.com/ilyagr/5d6339fb7dac5e7ab06fe1561ec62d45
edit-args = ["-f", "-d"]
edit-args = ["-f", "-d", "$left", "$right"]
Loading