| 1 |
# Configuration |
| 2 |
|
| 3 |
These are the config settings available to jj/Jujutsu. |
| 4 |
|
| 5 |
## Config files and TOML |
| 6 |
|
| 7 |
`jj` loads several types of config settings: |
| 8 |
|
| 9 |
- The built-in settings. These cannot be edited. They can be viewed in the |
| 10 |
[`cli/src/config/`] directory in `jj`'s source repo. |
| 11 |
|
| 12 |
- The user settings. These can be edited with `jj config edit --user`. User |
| 13 |
settings are located in [the user config files], which can be found with |
| 14 |
`jj config path --user`. |
| 15 |
|
| 16 |
- The repo settings. These can be edited with `jj config edit --repo`, or found |
| 17 |
with `jj config path --repo`. For security reasons, they are not located |
| 18 |
inside the repo. |
| 19 |
|
| 20 |
- The workspace settings. These can be edited with `jj config edit --workspace`, |
| 21 |
or found with `jj config path --workspace`. For security reasons, they are not |
| 22 |
located inside the workspace. |
| 23 |
|
| 24 |
- Settings [specified on the command-line]. |
| 25 |
|
| 26 |
These are listed in the order they are loaded; the settings from earlier items |
| 27 |
in the list are overridden by the settings from later items if they disagree. |
| 28 |
Every type of config except for the built-in settings is optional. |
| 29 |
|
| 30 |
Individual config files can also be targeted with |
| 31 |
`jj config {edit,set,unset} --file <PATH>`. |
| 32 |
|
| 33 |
You can enable JSON Schema validation in your editor by adding a `#:schema` |
| 34 |
reference at the top of your TOML config files. See [JSON Schema Support] for |
| 35 |
details. |
| 36 |
|
| 37 |
See the [TOML site] and the [syntax guide] for a detailed description of the |
| 38 |
syntax. We cover some of the basics below. |
| 39 |
|
| 40 |
The first thing to remember is that the value of a setting (the part to the |
| 41 |
right of the `=` sign) should be surrounded in quotes if it's a string. |
| 42 |
|
| 43 |
[`cli/src/config/`]: https://github.com/jj-vcs/jj/blob/main/cli/src/config/ |
| 44 |
[JSON Schema Support]: #json-schema-support |
| 45 |
[specified on the command-line]: #specifying-config-on-the-command-line |
| 46 |
[syntax guide]: https://toml.io/en/latest |
| 47 |
[the user config files]: #user-config-files |
| 48 |
[TOML site]: https://toml.io/en/ |
| 49 |
|
| 50 |
### Dotted style and headings |
| 51 |
|
| 52 |
In TOML, anything under a heading can be dotted instead. For example, |
| 53 |
`user.name = "YOUR NAME"` is equivalent to: |
| 54 |
|
| 55 |
```toml |
| 56 |
[user] |
| 57 |
name = "YOUR NAME" |
| 58 |
``` |
| 59 |
|
| 60 |
For future reference, here are a couple of more complicated examples, |
| 61 |
|
| 62 |
```toml |
| 63 |
# Dotted style |
| 64 |
template-aliases."format_short_id(id)" = "id.shortest(12)" |
| 65 |
colors."commit_id prefix".bold = true |
| 66 |
|
| 67 |
# is equivalent to: |
| 68 |
[template-aliases] |
| 69 |
"format_short_id(id)" = "id.shortest(12)" |
| 70 |
|
| 71 |
[colors] |
| 72 |
"commit_id prefix" = { bold = true } |
| 73 |
``` |
| 74 |
|
| 75 |
The docs below refer to keys in text using dotted notation, but example blocks |
| 76 |
will use heading notation to be unambiguous. If you are confident with TOML then |
| 77 |
use whichever suits you in your config. If you mix dotted keys and headings, |
| 78 |
**you must put the dotted keys before the first heading**. |
| 79 |
|
| 80 |
### Escapes in strings |
| 81 |
|
| 82 |
There are two (or four) types of [strings in TOML]: basic and literal, with |
| 83 |
multi-line versions of each. Basic strings use double quotes (`"`) and support |
| 84 |
escape sequences, such as `"\n"`, `"\""`, `"\\"`, etc. Literal strings use |
| 85 |
single quotes (`'`) and do not support escape sequences. Using 3 double quotes |
| 86 |
or 3 single quotes to wrap a string makes it multi-line, and then you can use an |
| 87 |
unescaped double quote or single quote respectively without ending the string. |
| 88 |
|
| 89 |
A string in your config may be interpreted twice, first by the TOML parser and |
| 90 |
then by a Jujutsu parser. To avoid putting strings in your config that the TOML |
| 91 |
parser processes before it gets to the Jujutsu parser, you may want to use |
| 92 |
literal strings or literal multi-line strings in your `config.toml` files. For |
| 93 |
example: |
| 94 |
|
| 95 |
```toml |
| 96 |
[template-aliases] |
| 97 |
# basic_template = "'hello' ++ \"\n\"" |
| 98 |
literal_template = '"hello" ++ "\n"' |
| 99 |
``` |
| 100 |
|
| 101 |
`basic_template` is actually equivalent to this string: |
| 102 |
|
| 103 |
``` |
| 104 |
'hello' ++ " |
| 105 |
" |
| 106 |
``` |
| 107 |
|
| 108 |
because the TOML parser interprets the `\n` character as part of the string. |
| 109 |
This causes the Jujutsu parser to receive a different string than what you |
| 110 |
literally see in the TOML file, which may result in seemingly confusing parse |
| 111 |
error messages (such as referencing a line that you think shouldn't exist). |
| 112 |
|
| 113 |
On the other hand, `literal_template` is equivalent to: |
| 114 |
|
| 115 |
``` |
| 116 |
"hello" ++ "\n" |
| 117 |
``` |
| 118 |
|
| 119 |
because the TOML parser does not escape anything in the literal string. |
| 120 |
|
| 121 |
The same rules of basic and literal strings apply to custom Jujutsu languages: |
| 122 |
double quotes (`"`) allow escapes whereas single quotes (`'`) do not. So |
| 123 |
`template-aliases.my_template = "'hello\\n'"` would probably not be what you |
| 124 |
want. |
| 125 |
|
| 126 |
[strings in TOML]: https://toml.io/en/latest#string |
| 127 |
|
| 128 |
## User settings |
| 129 |
|
| 130 |
```toml |
| 131 |
[user] |
| 132 |
name = "YOUR NAME" |
| 133 |
email = "[email protected]" |
| 134 |
``` |
| 135 |
|
| 136 |
Don't forget to change these to your own details! |
| 137 |
|
| 138 |
## UI settings |
| 139 |
|
| 140 |
### Colorizing output |
| 141 |
|
| 142 |
Possible values are `always`, `never`, `debug` and `auto` (default: `auto`). |
| 143 |
`auto` will use color only when writing to a terminal. `debug` will print the |
| 144 |
active labels alongside the regular colorized output. |
| 145 |
|
| 146 |
This setting overrides the `NO_COLOR` environment variable (if set). |
| 147 |
|
| 148 |
```toml |
| 149 |
[ui] |
| 150 |
color = "never" # Turn off color |
| 151 |
``` |
| 152 |
|
| 153 |
### Custom colors and styles |
| 154 |
|
| 155 |
You can customize the colors used for various elements of the UI. For example: |
| 156 |
|
| 157 |
```toml |
| 158 |
[colors] |
| 159 |
commit_id = "green" |
| 160 |
``` |
| 161 |
|
| 162 |
The following colors are available: |
| 163 |
|
| 164 |
* black |
| 165 |
* red |
| 166 |
* green |
| 167 |
* yellow |
| 168 |
* blue |
| 169 |
* magenta |
| 170 |
* cyan |
| 171 |
* white |
| 172 |
* default |
| 173 |
|
| 174 |
All of them but "default" come in a bright version too, e.g. "bright red". The |
| 175 |
"default" color can be used to override a color defined by a parent style |
| 176 |
(explained below). |
| 177 |
|
| 178 |
You can also use a 6-digit hex code for more control over the exact color used: |
| 179 |
|
| 180 |
```toml |
| 181 |
[colors] |
| 182 |
change_id = "#ff1525" |
| 183 |
``` |
| 184 |
|
| 185 |
`jj` also supports colors from the [ANSI 256-color palette] as `ansi-color-<N>`, |
| 186 |
where `<N>` is a number between 0 and 255: |
| 187 |
|
| 188 |
```toml |
| 189 |
[colors] |
| 190 |
commit_id = "ansi-color-81" |
| 191 |
``` |
| 192 |
|
| 193 |
[ANSI 256-color palette]: https://en.wikipedia.org/wiki/ANSI_escape_code#8-bit |
| 194 |
|
| 195 |
If you use a string value for a color, as in the examples above, it will be used |
| 196 |
for the foreground color. You can also set the background color, reverse colors |
| 197 |
(swap foreground and background), or make the text bold, dim, italic, |
| 198 |
underlined, or crossed-out. For that, you need to use a table: |
| 199 |
|
| 200 |
```toml |
| 201 |
[colors] |
| 202 |
commit_id = { fg = "green", bg = "#ff1525", bold = true, underline = true } |
| 203 |
change_id = { reverse = true, dim = false, italic = true } |
| 204 |
``` |
| 205 |
|
| 206 |
The key names are called "labels". The above used `commit_id` as label. You can |
| 207 |
also create rules combining multiple labels. The rules work a bit like CSS |
| 208 |
selectors. For example, if you want to color commit IDs green in general but |
| 209 |
make the commit ID of the working-copy commit also be underlined, you can do |
| 210 |
this: |
| 211 |
|
| 212 |
```toml |
| 213 |
[colors] |
| 214 |
commit_id = "green" |
| 215 |
"working_copy commit_id" = { underline = true } |
| 216 |
``` |
| 217 |
|
| 218 |
Parts of the style that are not overridden - such as the foreground color in the |
| 219 |
example above - are inherited from the style of the parent label. |
| 220 |
|
| 221 |
Which elements can be colored is not yet documented, but see |
| 222 |
the [default color configuration](https://github.com/jj-vcs/jj/blob/main/cli/src/config/colors.toml) |
| 223 |
for some examples of what's possible. |
| 224 |
|
| 225 |
### Default command |
| 226 |
|
| 227 |
When `jj` is run with no explicit subcommand, the value of the |
| 228 |
`ui.default-command` setting will be used instead. Possible values are any valid |
| 229 |
subcommand name, subcommand alias, or user-defined alias (defaults to `"log"`). |
| 230 |
|
| 231 |
```toml |
| 232 |
[ui] |
| 233 |
default-command = ["log", "--reversed"] |
| 234 |
``` |
| 235 |
|
| 236 |
### Default description |
| 237 |
|
| 238 |
The editor content of a commit description can be populated by the |
| 239 |
`draft_commit_description` template. `self` is a [`Commit` |
| 240 |
object](templates.md#commit-type). |
| 241 |
|
| 242 |
```toml |
| 243 |
[templates] |
| 244 |
draft_commit_description = ''' |
| 245 |
concat( |
| 246 |
builtin_draft_commit_description, |
| 247 |
"\nJJ: ignore-rest\n", |
| 248 |
diff.git(), |
| 249 |
) |
| 250 |
''' |
| 251 |
``` |
| 252 |
|
| 253 |
You can override only the `default_commit_description` value if you like, e.g.: |
| 254 |
|
| 255 |
```toml |
| 256 |
[template-aliases] |
| 257 |
default_commit_description = ''' |
| 258 |
" |
| 259 |
|
| 260 |
Closes #NNNN |
| 261 |
" |
| 262 |
''' |
| 263 |
``` |
| 264 |
|
| 265 |
### Duplicate commit description |
| 266 |
|
| 267 |
By default, `jj duplicate` copies the descriptions from the original commits. |
| 268 |
You can customize this behavior by specifying the `duplicate_description` |
| 269 |
template, which is given a [`Commit` object](templates.md#commit-type) of the |
| 270 |
original commit. |
| 271 |
|
| 272 |
```toml |
| 273 |
[templates] |
| 274 |
duplicate_description = ''' |
| 275 |
concat( |
| 276 |
description.trim_end(), |
| 277 |
"\n\n(cherry picked from commit ", |
| 278 |
commit_id, |
| 279 |
")\n" |
| 280 |
) |
| 281 |
''' |
| 282 |
``` |
| 283 |
|
| 284 |
Note that `description` usually ends with a `\n` if it is not blank. Use |
| 285 |
`.trim_end()` to remove the `\n`. |
| 286 |
|
| 287 |
### New commit description |
| 288 |
|
| 289 |
When `jj new` creates a commit without an explicit `-m` message, it evaluates |
| 290 |
the `new_description` template to populate the description. By default, this |
| 291 |
template is empty. |
| 292 |
|
| 293 |
You can customize this to automatically generate descriptions for new commits. |
| 294 |
For example, to auto-generate merge commit messages: |
| 295 |
|
| 296 |
```toml |
| 297 |
[templates] |
| 298 |
new_description = ''' |
| 299 |
if(parents.len() > 1, |
| 300 |
"Merge " ++ parents.skip(1).map(|p| try( |
| 301 |
p.bookmarks().first().name(), |
| 302 |
p.change_id().shortest(8) |
| 303 |
)).join(", ") ++ " into " ++ try( |
| 304 |
parents.first().bookmarks().first().name(), |
| 305 |
parents.first().change_id().shortest(8) |
| 306 |
) ++ "\n", |
| 307 |
"" |
| 308 |
) |
| 309 |
''' |
| 310 |
``` |
| 311 |
|
| 312 |
### Bookmark / tag listing order |
| 313 |
|
| 314 |
By default, `jj bookmark list` and `jj tag list` display bookmarks and tags |
| 315 |
sorted alphabetically by name. You can customize this sorting behavior by |
| 316 |
specifying sort keys in your config file: |
| 317 |
|
| 318 |
```toml |
| 319 |
[ui] |
| 320 |
bookmark-list-sort-keys = ["name"] |
| 321 |
tag-list-sort-keys = ["name"] |
| 322 |
``` |
| 323 |
|
| 324 |
The configuration works identically to using the `--sort` option. The following |
| 325 |
sort keys are supported: `name`, `author-name`, `author-email`, `author-date`, |
| 326 |
`committer-name`, `committer-email`, `committer-date`. Suffix the key with `-` |
| 327 |
to sort in descending order. Multiple keys can be supplied here, the first key |
| 328 |
is the most significant. |
| 329 |
|
| 330 |
When the `--sort` option is used, the configuration is ignored. |
| 331 |
|
| 332 |
### Bookmark advance default targets |
| 333 |
|
| 334 |
The `jj bookmark advance` command moves bookmarks forward in the graph. The |
| 335 |
default values for what bookmarks to advance and where to advance them to are: |
| 336 |
|
| 337 |
```toml |
| 338 |
[revsets] |
| 339 |
bookmark-advance-from = 'heads(::to & bookmarks())' # The closest bookmarks |
| 340 |
bookmark-advance-to = '@' # To the current working copy |
| 341 |
``` |
| 342 |
|
| 343 |
The default `from` is likely to be a good fit for almost everyone. The `from` |
| 344 |
revset has access to `to`, allowing it to find bookmarks relative to the |
| 345 |
destination revision. |
| 346 |
|
| 347 |
The default `to` is largely up to your preference and workflow. One simple |
| 348 |
alternative which fits squash-heavy workflows is `@-`, while a more involved |
| 349 |
and versatile alternative that advances to the closest "pushable" revision is: |
| 350 |
|
| 351 |
```toml |
| 352 |
[revsets] |
| 353 |
bookmark-advance-to = 'closest_pushable(@)' |
| 354 |
|
| 355 |
[revset-aliases] |
| 356 |
# Closest revision that is mutable, described and either non-empty or a merge |
| 357 |
'closest_pushable(to)' = ''' |
| 358 |
heads(::to & mutable() & ~description(exact:"") & (~empty() | merges())) |
| 359 |
''' |
| 360 |
``` |
| 361 |
|
| 362 |
### Commit trailers |
| 363 |
|
| 364 |
You can configure automatic addition of one or more trailers to commit |
| 365 |
descriptions using the `commit_trailers` template. |
| 366 |
|
| 367 |
Each line of the template is an individual trailer, usually in `Key: Value` |
| 368 |
format. |
| 369 |
|
| 370 |
Trailers defined in this template are deduplicated with the existing |
| 371 |
description: if the entire line of a trailer is already present, it will not be |
| 372 |
added again. To deduplicate based only on the trailer key, use the |
| 373 |
`trailers.contains_key(key)` method within the template. |
| 374 |
|
| 375 |
```toml |
| 376 |
[templates] |
| 377 |
commit_trailers = ''' |
| 378 |
format_signed_off_by_trailer(self) |
| 379 |
++ if(!trailers.contains_key("Change-Id"), format_gerrit_change_id_trailer(self))''' |
| 380 |
``` |
| 381 |
|
| 382 |
Some ready-to-use trailer templates are available for frequently used trailers: |
| 383 |
* `format_signed_off_by_trailer(commit)` creates a "Signed-off-by" trailer |
| 384 |
using the committer info. |
| 385 |
* `format_gerrit_change_id_trailer(commit)` creates a "Change-Id" trailer |
| 386 |
suitable to be used with Gerrit. It is based Jujutsu's change id. |
| 387 |
|
| 388 |
Existing trailers are also accessible via `commit.trailers()`. |
| 389 |
|
| 390 |
### Diff colors and styles |
| 391 |
|
| 392 |
In color-words and git diffs, word-level hunks are rendered with underline. You |
| 393 |
can override the default style with the following keys: |
| 394 |
|
| 395 |
```toml |
| 396 |
[colors] |
| 397 |
# Highlight hunks with background |
| 398 |
"diff removed token" = { bg = "#221111", underline = false } |
| 399 |
"diff added token" = { bg = "#002200", underline = false } |
| 400 |
# Alternatively, swap colors |
| 401 |
"diff token" = { reverse = true, underline = false } |
| 402 |
``` |
| 403 |
|
| 404 |
In color-words diffs, line numbers of context lines are rendered with decreased |
| 405 |
intensity to highlight changed lines. You can also decrease intensity of context |
| 406 |
contents. |
| 407 |
|
| 408 |
```toml |
| 409 |
[colors] |
| 410 |
# Dim context line numbers (default) |
| 411 |
"diff context line_number" = { dim = true } |
| 412 |
# Dim context line numbers and contents (applies to color-words and git diffs) |
| 413 |
"diff context" = { dim = true } |
| 414 |
``` |
| 415 |
|
| 416 |
Colors and styles can be configured differently for each diff format: |
| 417 |
|
| 418 |
```toml |
| 419 |
[colors] |
| 420 |
# Dim unchanged parts of changed lines in color-words diffs |
| 421 |
"diff color_words removed" = { dim = true } |
| 422 |
"diff color_words added" = { dim = true } |
| 423 |
"diff color_words removed token" = { dim = false } |
| 424 |
"diff color_words added token" = { dim = false } |
| 425 |
``` |
| 426 |
|
| 427 |
### Diff format |
| 428 |
|
| 429 |
```toml |
| 430 |
[ui] |
| 431 |
# Builtin formats: ":color-words" (default), ":git", |
| 432 |
# ":summary", ":stat", ":types", ":name-only" |
| 433 |
# or external command name and arguments (see below) |
| 434 |
diff-formatter = ":git" |
| 435 |
``` |
| 436 |
|
| 437 |
#### Color-words diff options |
| 438 |
|
| 439 |
In color-words diffs, changed words are displayed inline by default when color |
| 440 |
is enabled. When the formatter cannot emit color, changed words are always shown |
| 441 |
on separate lines because inline changes would not be distinguishable. |
| 442 |
|
| 443 |
Because it's difficult to read a diff line with many removed/added words, there's |
| 444 |
a threshold to switch to traditional separate-line format in colorized output. |
| 445 |
You can also change the default number of lines of context shown. |
| 446 |
|
| 447 |
* `max-inline-alternation`: Maximum number of removed/added word alternation to |
| 448 |
inline. For example, `<added> ... <added>` sequence has 1 alternation, so the |
| 449 |
line will be inline if `max-inline-alternation >= 1`. `<added> ... <removed> |
| 450 |
... <added>` sequence has 3 alternation. |
| 451 |
|
| 452 |
* `0`: disable inlining, making `--color-words` more similar to `--git` |
| 453 |
* `1`: inline removes-only or adds-only lines |
| 454 |
* `2`, `3`, ..: inline up to `2`, `3`, .. alternation |
| 455 |
* `-1`: inline all lines |
| 456 |
|
| 457 |
The default is `3`. |
| 458 |
|
| 459 |
**This parameter is experimental.** The definition is subject to change. |
| 460 |
|
| 461 |
* `conflict`: How conflicts are processed and displayed. |
| 462 |
|
| 463 |
* `"materialize"`: compare materialized contents (default) |
| 464 |
* `"pair"`: compare individual pairs |
| 465 |
|
| 466 |
**This parameter is experimental.** |
| 467 |
|
| 468 |
* `context`: Number of lines of context to show in the diff. The default is `3`. |
| 469 |
|
| 470 |
```toml |
| 471 |
[diff.color-words] |
| 472 |
max-inline-alternation = 3 |
| 473 |
context = 3 |
| 474 |
``` |
| 475 |
|
| 476 |
#### Git diff options |
| 477 |
|
| 478 |
In git diffs you can change the default number of lines of context shown. |
| 479 |
|
| 480 |
* `context`: Number of lines of context to show in the diff. The default is `3`. |
| 481 |
|
| 482 |
* `show-path-prefix`: Whether to show the `a/` and `b/` path prefixes in |
| 483 |
`diff --git` output. The default is `true`. |
| 484 |
|
| 485 |
```toml |
| 486 |
[diff.git] |
| 487 |
context = 3 |
| 488 |
show-path-prefix = true |
| 489 |
``` |
| 490 |
|
| 491 |
#### Diff stat options |
| 492 |
|
| 493 |
When using a subcommand that displays the diff stat menu like `jj show --stat`, |
| 494 |
the bar portion that renders as `++--` can be limited to a maximum width in |
| 495 |
characters. |
| 496 |
|
| 497 |
```toml |
| 498 |
[diff.stat] |
| 499 |
max-bar-width = 10 |
| 500 |
``` |
| 501 |
|
| 502 |
By default without this option set, the bar width is unbounded and will use the |
| 503 |
remaining available space, with a minimum of 30% of the total width. |
| 504 |
|
| 505 |
### Generating diffs by external command |
| 506 |
|
| 507 |
If `ui.diff-formatter` is not a builtin format, the specified diff command will |
| 508 |
be called. |
| 509 |
|
| 510 |
```toml |
| 511 |
[ui] |
| 512 |
# Use Difftastic by default |
| 513 |
diff-formatter = ["difft", "--color=always", "$left", "$right"] |
| 514 |
# Use tool named "<name>" (see below) |
| 515 |
diff-formatter = "<name>" |
| 516 |
``` |
| 517 |
|
| 518 |
The external diff tool can also be enabled by `diff --tool <name>` argument. |
| 519 |
For the tool named `<name>`, command arguments can be configured as follows. |
| 520 |
|
| 521 |
```toml |
| 522 |
[merge-tools.<name>] |
| 523 |
# program = "<name>" # Defaults to the name of the tool if not specified |
| 524 |
diff-args = ["--color=always", "$left", "$right"] |
| 525 |
``` |
| 526 |
|
| 527 |
- `$left` and `$right` are replaced with the paths to the left and right |
| 528 |
directories to diff respectively. |
| 529 |
|
| 530 |
- `$width` is replaced with the number of terminal columns available to the diff |
| 531 |
content. |
| 532 |
|
| 533 |
- If `diff-args` is not specified, `["$left", "$right"]` will be used by default. |
| 534 |
|
| 535 |
- If `diff-args = []`, `jj` will refuse to use this tool for diff formatting. |
| 536 |
This is a way to explicitly state that a certain tool (e.g. `mergiraf`) does |
| 537 |
not work for viewing diffs. |
| 538 |
|
| 539 |
By default `jj` will invoke external tools with a directory containing the left |
| 540 |
and right sides. The `diff-invocation-mode` config can change this to file by file |
| 541 |
invocations as follows: |
| 542 |
|
| 543 |
```toml |
| 544 |
[ui] |
| 545 |
diff-formatter = "vimdiff" |
| 546 |
|
| 547 |
[merge-tools.vimdiff] |
| 548 |
diff-invocation-mode = "file-by-file" |
| 549 |
``` |
| 550 |
|
| 551 |
By default `jj` will display a warning when the command exits with a non-success |
| 552 |
error code. The `diff-expected-exit-codes` config can suppress this warning |
| 553 |
message for specific exit codes: |
| 554 |
|
| 555 |
```toml |
| 556 |
[merge-tools.delta] |
| 557 |
diff-expected-exit-codes = [0, 1] |
| 558 |
``` |
| 559 |
|
| 560 |
### Conflict marker style |
| 561 |
|
| 562 |
You can configure which style of conflict markers to use when materializing |
| 563 |
conflicts: |
| 564 |
|
| 565 |
```toml |
| 566 |
[ui] |
| 567 |
# Shows a single snapshot and one or more diffs to apply to it |
| 568 |
conflict-marker-style = "diff" |
| 569 |
# Shows a snapshot for each side and base of the conflict |
| 570 |
conflict-marker-style = "snapshot" |
| 571 |
# Uses Git's "diff3" conflict markers to support tools that depend on it |
| 572 |
conflict-marker-style = "git" |
| 573 |
``` |
| 574 |
|
| 575 |
For more details about these conflict marker styles, see the [conflicts |
| 576 |
page](conflicts.md#conflict-markers). |
| 577 |
|
| 578 |
### Set of immutable commits |
| 579 |
|
| 580 |
You can configure the set of immutable commits via |
| 581 |
`revset-aliases."immutable_heads()"`. The default set of immutable heads is |
| 582 |
`builtin_immutable_heads()`, which in turn is defined as `trunk() | tags() | |
| 583 |
untracked_remote_bookmarks() | untracked_remote_tags()`. For example, to also |
| 584 |
consider the `release@origin` bookmark immutable: |
| 585 |
|
| 586 |
```toml |
| 587 |
[revset-aliases] |
| 588 |
"immutable_heads()" = "builtin_immutable_heads() | release@origin" |
| 589 |
``` |
| 590 |
|
| 591 |
To prevent rewriting commits authored by other users: |
| 592 |
|
| 593 |
```toml |
| 594 |
# The `trunk().. &` bit is an optimization to scan for non-`mine()` commits |
| 595 |
# only among commits that are not in `trunk()`. |
| 596 |
[revset-aliases] |
| 597 |
"immutable_heads()" = "builtin_immutable_heads() | (trunk().. & ~mine())" |
| 598 |
``` |
| 599 |
|
| 600 |
Ancestors of the configured set are also immutable. The root commit is always |
| 601 |
immutable even if the set is empty. |
| 602 |
|
| 603 |
Immutable commits (other than the root commit) can be rewritten using the |
| 604 |
`--ignore-immutable` CLI flag. |
| 605 |
|
| 606 |
!!! warning |
| 607 |
|
| 608 |
Using `--ignore-immutable` will allow you to rewrite any commit in the |
| 609 |
history, and all descendants, without warning. Use this power wisely, and |
| 610 |
remember `jj undo`. |
| 611 |
|
| 612 |
### Behavior of prev and next commands |
| 613 |
|
| 614 |
If you prefer using an "edit-based" workflow, rather than squashing |
| 615 |
modifications into parent changes, you may find yourself using the `prev` and |
| 616 |
`next` commands with their `--edit` flag often to move between your changes. You |
| 617 |
can avoid having to type the `--edit` flag every time you need it by actually |
| 618 |
making it the default: |
| 619 |
|
| 620 |
```toml |
| 621 |
[ui.movement] |
| 622 |
edit = true |
| 623 |
``` |
| 624 |
|
| 625 |
You can pass the `--no-edit` flag to `prev` and `next` if you find yourself |
| 626 |
needing the original behavior. |
| 627 |
|
| 628 |
## List |
| 629 |
|
| 630 |
### Default Template |
| 631 |
|
| 632 |
You can configure the template used when no `-T` is specified. |
| 633 |
|
| 634 |
- `templates.config_list` for `jj config list` |
| 635 |
- `templates.workspace_list` for `jj workspace list` |
| 636 |
|
| 637 |
If you want to see the config variable origin (type and path) when you do `jj config list` |
| 638 |
you can add this to your config: |
| 639 |
|
| 640 |
```toml |
| 641 |
[templates] |
| 642 |
config_list = "builtin_config_list_detailed" |
| 643 |
``` |
| 644 |
|
| 645 |
## Log |
| 646 |
|
| 647 |
### Default revisions |
| 648 |
|
| 649 |
You can configure the revisions `jj log` would show when neither `-r` nor any paths are specified. |
| 650 |
|
| 651 |
```toml |
| 652 |
[revsets] |
| 653 |
# Show commits that are not in `main@origin` |
| 654 |
log = "main@origin.." |
| 655 |
``` |
| 656 |
|
| 657 |
The default value for `revsets.log` is `builtin_log()`, which is defined as |
| 658 |
`'present(@) | ancestors(immutable_heads().., 2) | trunk()'`. You can use |
| 659 |
`builtin_log()` as a starting point for your own custom log revset. |
| 660 |
|
| 661 |
!!! warning |
| 662 |
|
| 663 |
When `revsets.short-prefixes` is not specified, it defaults to the value of `revsets.log`. This |
| 664 |
affects how change and commit id references are resolved when multiple commits share a common |
| 665 |
prefix. Changing `revsets.log` without also setting `revsets.short-prefixes` might increase the |
| 666 |
length of prefixes needed on the command-line, especially in large repositories. |
| 667 |
|
| 668 |
### Default revisions for operation diffs |
| 669 |
|
| 670 |
You can configure the set of revisions that are considered "interesting" when |
| 671 |
showing the difference between two operations (e.g. in `jj op show`, |
| 672 |
`jj op diff`, or `jj op log -p`). Revisions that are not in this set are |
| 673 |
elided into a summary count. |
| 674 |
|
| 675 |
```toml |
| 676 |
[revsets] |
| 677 |
# Only show mutable revisions and the trunk |
| 678 |
op-diff-changes-in = "mutable() | trunk()" |
| 679 |
``` |
| 680 |
|
| 681 |
The default value for `revsets.op-diff-changes-in` is |
| 682 |
`'mutable() | immutable_heads()'`. |
| 683 |
|
| 684 |
### Prioritize Revsets in the Log over @ |
| 685 |
|
| 686 |
In some situations the default graph can be hard to read, for example when working with big merges. |
| 687 |
To improve this behavior you can configure which revset in the `jj log` graph is displayed on |
| 688 |
the left instead of `@`. |
| 689 |
|
| 690 |
The following example will prioritize the change with the description "megamerge" with a fallback |
| 691 |
to `trunk()` in case no such change exists: |
| 692 |
|
| 693 |
```toml |
| 694 |
[revsets] |
| 695 |
log-graph-prioritize = 'coalesce(description("megamerge\n"), trunk())' |
| 696 |
``` |
| 697 |
|
| 698 |
### Default Template |
| 699 |
|
| 700 |
You can configure the template used when no `-T` is specified. |
| 701 |
|
| 702 |
- `templates.evolog` for `jj evolog` |
| 703 |
- `templates.log` for `jj log` |
| 704 |
- `templates.show` for `jj show` |
| 705 |
- `templates.op_log` for `jj op log` |
| 706 |
- `templates.op_show` for `jj op show` |
| 707 |
|
| 708 |
```toml |
| 709 |
[templates] |
| 710 |
# Use builtin evolog template |
| 711 |
evolog = "builtin_evolog_compact" |
| 712 |
# Use builtin log template |
| 713 |
log = "builtin_log_compact" |
| 714 |
# Use builtin show template |
| 715 |
show = "builtin_log_detailed" |
| 716 |
# Use builtin op log template |
| 717 |
op_log = "builtin_op_log_compact" |
| 718 |
# Use builtin op log template |
| 719 |
op_show = "builtin_op_log_compact" |
| 720 |
``` |
| 721 |
|
| 722 |
If you want to see the full description when you do `jj log` you can add this to |
| 723 |
your config: |
| 724 |
|
| 725 |
```toml |
| 726 |
[templates] |
| 727 |
log = "builtin_log_compact_full_description" |
| 728 |
``` |
| 729 |
|
| 730 |
### Graph style |
| 731 |
|
| 732 |
```toml |
| 733 |
[ui] |
| 734 |
# Possible values: "curved" (default), "square", "ascii", "ascii-large" |
| 735 |
graph.style = "square" |
| 736 |
``` |
| 737 |
|
| 738 |
#### Node style |
| 739 |
|
| 740 |
The symbols used to represent commits or operations can be customized via |
| 741 |
templates. |
| 742 |
|
| 743 |
- `templates.log_node` for commits (with `Option<Commit>` keywords) |
| 744 |
- `templates.op_log_node` for operations (with `Operation` keywords) |
| 745 |
|
| 746 |
For example: |
| 747 |
|
| 748 |
```toml |
| 749 |
[templates] |
| 750 |
log_node = ''' |
| 751 |
coalesce( |
| 752 |
if(!self, "š®"), |
| 753 |
if(current_working_copy, "@"), |
| 754 |
if(root, "ā“"), |
| 755 |
if(immutable, "ā", "ā"), |
| 756 |
) |
| 757 |
''' |
| 758 |
op_log_node = 'if(current_operation, "@", "ā")' |
| 759 |
``` |
| 760 |
|
| 761 |
### Wrap log content |
| 762 |
|
| 763 |
If enabled, `log`/`evolog`/`op log` content will be wrapped based on |
| 764 |
the terminal width. |
| 765 |
|
| 766 |
```toml |
| 767 |
[ui] |
| 768 |
log-word-wrap = true |
| 769 |
``` |
| 770 |
|
| 771 |
### Display of commit and change ids |
| 772 |
|
| 773 |
Can be customized by the `format_short_id()` template alias. |
| 774 |
|
| 775 |
```toml |
| 776 |
[template-aliases] |
| 777 |
# Highlight unique prefix and show at least 12 characters (default) |
| 778 |
'format_short_id(id)' = 'id.shortest(12)' |
| 779 |
# Just the shortest possible unique prefix |
| 780 |
'format_short_id(id)' = 'id.shortest()' |
| 781 |
# Show unique prefix and the rest surrounded by brackets |
| 782 |
'format_short_id(id)' = 'id.shortest(12).prefix() ++ "[" ++ id.shortest(12).rest() ++ "]"' |
| 783 |
# Always show 12 characters |
| 784 |
'format_short_id(id)' = 'id.short(12)' |
| 785 |
``` |
| 786 |
|
| 787 |
To customize these separately, use the `format_short_commit_id()` and |
| 788 |
`format_short_change_id()` aliases: |
| 789 |
|
| 790 |
```toml |
| 791 |
[template-aliases] |
| 792 |
# Uppercase change ids. `jj` treats change and commit ids as case-insensitive. |
| 793 |
'format_short_change_id(id)' = 'format_short_id(id).upper()' |
| 794 |
``` |
| 795 |
|
| 796 |
Operation ids can be customized by the `format_short_operation_id()` alias: |
| 797 |
|
| 798 |
```toml |
| 799 |
[template-aliases] |
| 800 |
# Always show 12 characters |
| 801 |
'format_short_operation_id(id)' = 'id.short(12)' |
| 802 |
``` |
| 803 |
|
| 804 |
To get shorter prefixes for certain revisions, set `revsets.short-prefixes`: |
| 805 |
|
| 806 |
```toml |
| 807 |
[revsets] |
| 808 |
# Prioritize the current bookmark |
| 809 |
short-prefixes = "(main..@)::" |
| 810 |
``` |
| 811 |
|
| 812 |
### Relative timestamps |
| 813 |
|
| 814 |
Can be customized by the `format_timestamp()` template alias. |
| 815 |
|
| 816 |
```toml |
| 817 |
[template-aliases] |
| 818 |
# Full timestamp in ISO 8601 format |
| 819 |
'format_timestamp(timestamp)' = 'timestamp' |
| 820 |
# Relative timestamp rendered as "x days/hours/seconds ago" |
| 821 |
'format_timestamp(timestamp)' = 'timestamp.ago()' |
| 822 |
``` |
| 823 |
|
| 824 |
`jj op log` defaults to relative timestamps. To use absolute timestamps, you |
| 825 |
will need to modify the `format_time_range()` template alias. |
| 826 |
|
| 827 |
```toml |
| 828 |
[template-aliases] |
| 829 |
'format_time_range(time_range)' = 'time_range.start() ++ " - " ++ time_range.end()' |
| 830 |
``` |
| 831 |
|
| 832 |
### Author format |
| 833 |
|
| 834 |
Can be customized by the `format_short_signature()` template alias. |
| 835 |
|
| 836 |
```toml |
| 837 |
[template-aliases] |
| 838 |
# Full email address (default) |
| 839 |
'format_short_signature(signature)' = 'signature.email()' |
| 840 |
# Both name and email address |
| 841 |
'format_short_signature(signature)' = 'signature' |
| 842 |
# Username part of the email address |
| 843 |
'format_short_signature(signature)' = 'signature.email().local()' |
| 844 |
``` |
| 845 |
|
| 846 |
### Commit timestamp |
| 847 |
|
| 848 |
Commits have both an "author timestamp" and "committer timestamp". By default, |
| 849 |
jj displays the committer timestamp, but can be changed to show the author |
| 850 |
timestamp instead. |
| 851 |
|
| 852 |
The function must return a timestamp because the return value will likely be |
| 853 |
formatted with `format_timestamp()`. |
| 854 |
|
| 855 |
```toml |
| 856 |
[template-aliases] |
| 857 |
'commit_timestamp(commit)' = 'commit.author().timestamp()' |
| 858 |
``` |
| 859 |
|
| 860 |
### Signature format |
| 861 |
|
| 862 |
Can be enabled with `ui.show-cryptographic-signatures`, and |
| 863 |
customized with `format_short_cryptographic_signature(sig)` and |
| 864 |
`format_detailed_cryptographic_signature(sig)`. |
| 865 |
|
| 866 |
Note that the formatting functions take an `Option<CryptographicSignature>`. |
| 867 |
This allows you to emit a custom message if a signature is not present, but |
| 868 |
will raise an error if you try to access methods on a signature that is not |
| 869 |
available. |
| 870 |
|
| 871 |
```toml |
| 872 |
[ui] |
| 873 |
# default is false |
| 874 |
show-cryptographic-signatures = true |
| 875 |
|
| 876 |
[template-aliases] |
| 877 |
'format_short_cryptographic_signature(sig)' = ''' |
| 878 |
if(sig, |
| 879 |
sig.status(), |
| 880 |
"(no sig)", |
| 881 |
) |
| 882 |
''' |
| 883 |
``` |
| 884 |
|
| 885 |
## Pager |
| 886 |
|
| 887 |
By default, jj will paginate output that would scroll off the screen. It does |
| 888 |
this by passing output through `less -FRXK` on most platforms (on Windows it uses |
| 889 |
[the pager](#builtin-pager) that is built-in to jj). |
| 890 |
|
| 891 |
Which pager to use can be customized by setting `ui.pager`. When choosing a |
| 892 |
pager, ensure that it either supports color codes or that you disable color (see |
| 893 |
[Colorizing output](#colorizing-output)). |
| 894 |
|
| 895 |
The `JJ_PAGER` environment variable overrides `ui.pager`, and is useful for |
| 896 |
tool-specific environments that should not affect other programs. The generic |
| 897 |
`PAGER` environment variable is ignored. |
| 898 |
|
| 899 |
Examples: |
| 900 |
|
| 901 |
```shell |
| 902 |
# Pipe output through `less -FRXK` (default on non-Windows platforms) |
| 903 |
$ jj config set --user ui.pager "less -FRXK" |
| 904 |
|
| 905 |
# Use the built-in pager (default on Windows) |
| 906 |
$ jj config set --user ui.pager :builtin |
| 907 |
|
| 908 |
# Use `$PAGER` environment variable if set (on non-Windows platforms) |
| 909 |
$ jj config set --user ui.pager '["sh", "-c", "exec ${PAGER:-less -FRXK}"]' |
| 910 |
``` |
| 911 |
|
| 912 |
Additionally, paging behavior can be toggled via `ui.paginate` like so: |
| 913 |
|
| 914 |
```toml |
| 915 |
[ui] |
| 916 |
# Enable pagination for commands that support it (default) |
| 917 |
paginate = "auto" |
| 918 |
# Disable all pagination, equivalent to using --no-pager |
| 919 |
paginate = "never" |
| 920 |
``` |
| 921 |
|
| 922 |
### Builtin pager |
| 923 |
|
| 924 |
Our builtin pager is based on |
| 925 |
[`streampager`](https://github.com/markbt/streampager/) but is configured within |
| 926 |
`jj`'s config. It is configured via the `ui.streampager` table. |
| 927 |
|
| 928 |
#### Key bindings |
| 929 |
|
| 930 |
The built-in pager supports both navigation via arrows and Vim-style navigation. |
| 931 |
Beyond that, here are some useful keybindings for the pager: |
| 932 |
|
| 933 |
| Key | Action | |
| 934 |
| :-------------- | :-------------------- | |
| 935 |
| `Ctrl-c` or `q` | Quit | |
| 936 |
| `h` or `F1` | Show all key bindings | |
| 937 |
| `Esc` | Close help or prompt | |
| 938 |
| `\` | Toggle line wrapping | |
| 939 |
| `#` | Toggle line numbers | |
| 940 |
| `Ctrl-r` | Toggle the ruler | |
| 941 |
|
| 942 |
The built-in pager does not support mouse input. |
| 943 |
|
| 944 |
#### Wrapping config |
| 945 |
|
| 946 |
Wrapping performed by the pager happens *in addition to* any |
| 947 |
wrapping that `jj` itself does. |
| 948 |
|
| 949 |
```toml |
| 950 |
[ui.streampager] |
| 951 |
wrapping = "anywhere" # wrap at screen edge (default) |
| 952 |
wrapping = "word" # wrap on word boundaries |
| 953 |
wrapping = "none" # strip long lines, allow scrolling |
| 954 |
# left and right like `less -S` |
| 955 |
``` |
| 956 |
|
| 957 |
#### Auto-exit, clearing the screen on startup or exit |
| 958 |
|
| 959 |
You can configure whether the pager clears the screen on startup or exit, and |
| 960 |
whether it quits automatically on short inputs. When the pager auto-quits, |
| 961 |
features like word-wrapping are disabled. |
| 962 |
|
| 963 |
```toml |
| 964 |
[ui.streampager] |
| 965 |
# Do not clear screen on exit. Use a full-screen interface for long |
| 966 |
# output only. Like `less -FX`. |
| 967 |
interface = "quit-if-one-page" # (default). |
| 968 |
# Always use a full-screen interface, ask the terminal to clear the |
| 969 |
# screen on exit. Like `less -+FX`. |
| 970 |
interface = "full-screen-clear-output" |
| 971 |
# Use the alternate screen if the input is either long or takes more |
| 972 |
# than 2 seconds to finish. Similar but not identical to `less -F -+X`. |
| 973 |
interface = "quit-quickly-or-clear-output" |
| 974 |
``` |
| 975 |
|
| 976 |
#### Showing the ruler on startup |
| 977 |
|
| 978 |
```toml |
| 979 |
[ui.streampager] |
| 980 |
# Start with the ruler showing |
| 981 |
show-ruler = true # (default) |
| 982 |
# Start with the ruler hidden |
| 983 |
show-ruler = false |
| 984 |
``` |
| 985 |
|
| 986 |
### Processing contents to be paged |
| 987 |
|
| 988 |
If you'd like to pass the output through a formatter e.g. |
| 989 |
[`diff-so-fancy`](https://github.com/so-fancy/diff-so-fancy) before piping it |
| 990 |
through a pager you must do it using a subshell as, unlike `git` or `hg`, the |
| 991 |
command will be executed directly. For example: |
| 992 |
|
| 993 |
```toml |
| 994 |
[ui] |
| 995 |
pager = ["sh", "-c", "diff-so-fancy | less -RFX"] |
| 996 |
``` |
| 997 |
|
| 998 |
Some formatters (like [`delta`](https://github.com/dandavison/delta)) require |
| 999 |
git style diffs for formatting. You can configure this style of |
| 1000 |
diff as the default with the `ui.diff-formatter` setting. For example: |
| 1001 |
|
| 1002 |
```toml |
| 1003 |
[ui] |
| 1004 |
pager = "delta" |
| 1005 |
diff-formatter = ":git" |
| 1006 |
``` |
| 1007 |
|
| 1008 |
## Aliases |
| 1009 |
|
| 1010 |
You can define aliases for commands, including their arguments. For example: |
| 1011 |
|
| 1012 |
```toml |
| 1013 |
[aliases] |
| 1014 |
# `jj l` shows commits on the working-copy commit's (anonymous) bookmark |
| 1015 |
# compared to the `main` bookmark |
| 1016 |
l = ["log", "-r", "(main..@):: | (main..@)-"] |
| 1017 |
``` |
| 1018 |
|
| 1019 |
### Alias descriptions |
| 1020 |
|
| 1021 |
Alias descriptions can be surfaced in shell completions by defining the alias |
| 1022 |
as a table with `.doc` and `.definition` properties. For example: |
| 1023 |
|
| 1024 |
```toml |
| 1025 |
[aliases] |
| 1026 |
l = { |
| 1027 |
definition = ["log", "-r", "(main..@):: | (main..@)-"], |
| 1028 |
doc = "Log pending changes" |
| 1029 |
} |
| 1030 |
``` |
| 1031 |
|
| 1032 |
You can also use the dotted key syntax: |
| 1033 |
|
| 1034 |
```toml |
| 1035 |
[aliases] |
| 1036 |
l.definition = ["log", "-r", "(main..@):: | (main..@)-"] |
| 1037 |
l.doc = "Log pending changes" |
| 1038 |
``` |
| 1039 |
|
| 1040 |
This alias syntax can only run a single jj command. However, you may want to |
| 1041 |
execute multiple jj commands with a single alias, or run arbitrary scripts that |
| 1042 |
complement your version control workflow. This can be done, but be aware of the |
| 1043 |
danger: |
| 1044 |
|
| 1045 |
!!! warning |
| 1046 |
|
| 1047 |
The following technique just provides a convenient syntax for running |
| 1048 |
arbitrary code on your system. Using it irresponsibly may cause damage |
| 1049 |
ranging from breaking the behavior of `jj undo` to wiping your file system. |
| 1050 |
Exercise the same amount of caution while writing these aliases as you would |
| 1051 |
when typing commands into the terminal! |
| 1052 |
|
| 1053 |
This feature may be removed or replaced by an embedded scripting language in |
| 1054 |
the future. |
| 1055 |
|
| 1056 |
The command `jj util exec` will simply run any command you pass to it as an |
| 1057 |
argument. Additional arguments are passed through. Here are some examples: |
| 1058 |
|
| 1059 |
```toml |
| 1060 |
[aliases] |
| 1061 |
my-script = ["util", "exec", "--", "my-jj-script"] |
| 1062 |
# ^^^^ |
| 1063 |
# This makes sure that flags are passed to your script instead of parsed by jj. |
| 1064 |
my-inline-script = ["util", "exec", "--", "bash", "-c", """ |
| 1065 |
set -euo pipefail |
| 1066 |
echo "Look Ma, everything in one file!" |
| 1067 |
echo "args: $@" |
| 1068 |
""", ""] |
| 1069 |
# ^^ |
| 1070 |
# This last empty string will become "$0" in bash, so your actual arguments |
| 1071 |
# are all included in "$@" and start at "$1" as expected. |
| 1072 |
``` |
| 1073 |
|
| 1074 |
> Note: Shebangs (e.g. `#!/usr/bin/env`) aren't necessary since you're already |
| 1075 |
> explicitly passing your script into the right shell. |
| 1076 |
|
| 1077 |
## Editor |
| 1078 |
|
| 1079 |
The default editor is set via `ui.editor`, though there are several places to |
| 1080 |
set it. The priority is as follows (environment variables are marked with |
| 1081 |
a `$`): |
| 1082 |
|
| 1083 |
`$JJ_EDITOR` > `ui.editor` > `$VISUAL` > `$EDITOR` |
| 1084 |
|
| 1085 |
Nano is the default editor (Notepad on Windows) in the absence of any other |
| 1086 |
setting, but you could set it explicitly too. |
| 1087 |
|
| 1088 |
```toml |
| 1089 |
[ui] |
| 1090 |
editor = "pico" |
| 1091 |
``` |
| 1092 |
|
| 1093 |
To use NeoVim instead: |
| 1094 |
|
| 1095 |
```toml |
| 1096 |
[ui] |
| 1097 |
editor = "nvim" |
| 1098 |
``` |
| 1099 |
|
| 1100 |
For GUI editors you possibly need to use a `-w` or `--wait`. Some examples: |
| 1101 |
|
| 1102 |
```toml |
| 1103 |
[ui] |
| 1104 |
editor = "code -w" # VS Code |
| 1105 |
editor = "code.cmd -w" # VS Code on Windows |
| 1106 |
editor = "bbedit -w" # BBEdit |
| 1107 |
editor = "subl -n -w" # Sublime Text |
| 1108 |
editor = "mate -w" # TextMate |
| 1109 |
editor = ["C:/Program Files/Notepad++/notepad++.exe", |
| 1110 |
"-multiInst", "-notabbar", "-nosession", "-noPlugin"] # Notepad++ |
| 1111 |
editor = "idea --temp-project --wait" #IntelliJ |
| 1112 |
``` |
| 1113 |
|
| 1114 |
Obviously, you would only set one line, don't copy them all in! |
| 1115 |
|
| 1116 |
## Editing diffs |
| 1117 |
|
| 1118 |
The `ui.diff-editor` setting affects the default tool used for editing diffs |
| 1119 |
(e.g. `jj split`, `jj squash -i`). If it is not set, the special value |
| 1120 |
`:builtin` is used. It launches a built-in TUI tool (known as [scm-diff-editor]) |
| 1121 |
to edit the diff in your terminal. |
| 1122 |
|
| 1123 |
[scm-diff-editor]: https://github.com/arxanas/scm-record?tab=readme-ov-file#scm-diff-editor |
| 1124 |
|
| 1125 |
You can try a different tool temporarily by doing e.g. `jj split --tool meld` or |
| 1126 |
you can set the option to change the default. This requires that you have an |
| 1127 |
appropriate tool installed, see for example [the instructions for using |
| 1128 |
Meld](#using-meld-as-a-diff-editor). |
| 1129 |
|
| 1130 |
**Suggestion:** If possible, it is recommended to try an external diff tool like |
| 1131 |
[Meld](#using-meld-as-a-diff-editor) (see below for some other possibilities) |
| 1132 |
for splitting commits and other diff editing, in addition to the built-in diff |
| 1133 |
editor. It is good to know the capabilities of both. The built-in diff editor |
| 1134 |
does not require external tools to be available, is faster for tasks like |
| 1135 |
picking hunks, and does not require leaving the terminal. External tools give |
| 1136 |
you the flexibility of picking out portions of lines from the diff or even |
| 1137 |
arbitrarily editing the text of the files. |
| 1138 |
|
| 1139 |
If `ui.diff-editor` is a string, e.g. `"meld"`, the arguments will be read from |
| 1140 |
the following config keys. |
| 1141 |
|
| 1142 |
```toml |
| 1143 |
[merge-tools.meld] |
| 1144 |
# program = "meld" # Defaults to the name of the tool if not specified |
| 1145 |
program = "/path/to/meld" # May be necessary if `meld` is not in the PATH |
| 1146 |
edit-args = ["--newtab", "$left", "$right"] |
| 1147 |
``` |
| 1148 |
|
| 1149 |
`jj` makes the following substitutions: |
| 1150 |
|
| 1151 |
- `$left` is a directory containing the original contents before any changes. |
| 1152 |
|
| 1153 |
- `$right` is the directory containing the changed contents. |
| 1154 |
Edits are read back from here, so this is where tools should make changes. |
| 1155 |
|
| 1156 |
- If no `edit-args` are specified, `["$left", "$right"]` are set by default. |
| 1157 |
|
| 1158 |
- If `edit-args = []`, `jj` will refuse to use this tool for diff editing. This is a way to explicitly state that a certain tool (e.g. `mergiraf`) does not work for diff editing. |
| 1159 |
|
| 1160 |
Like diff viewing, diff editors are invoked with a directory containing the left |
| 1161 |
and right sides by default. The `edit-invocation-mode` config controls this |
| 1162 |
independently of `diff-invocation-mode`, so you can, for example, keep |
| 1163 |
directory-based diff viewing but launch the diff editor once per changed file: |
| 1164 |
|
| 1165 |
```toml |
| 1166 |
[merge-tools.my-tool] |
| 1167 |
diff-invocation-mode = "dir" |
| 1168 |
edit-invocation-mode = "file-by-file" |
| 1169 |
``` |
| 1170 |
|
| 1171 |
Finally, `ui.diff-editor` can be a list that specifies a command and its arguments. |
| 1172 |
|
| 1173 |
Some examples: |
| 1174 |
|
| 1175 |
```toml |
| 1176 |
[ui] |
| 1177 |
# Use merge-tools.meld.edit-args |
| 1178 |
diff-editor = "meld" # Or `kdiff3`, or `diffedit3`, ... |
| 1179 |
# Specify edit-args inline |
| 1180 |
diff-editor = ["/path/to/binary", "--be-helpful", "$left", "$right"] |
| 1181 |
# Equivalent to ["binary", "$left", "$right"] arguments by default |
| 1182 |
diff-editor = "binary" |
| 1183 |
``` |
| 1184 |
|
| 1185 |
### Experimental 3-pane diff editing |
| 1186 |
|
| 1187 |
We offer two special "3-pane" diff editor configs: |
| 1188 |
|
| 1189 |
- `meld-3`, which requires installing [Meld](https://meldmerge.org/), and |
| 1190 |
- `diffedit3`, which requires installing [`diffedit3`](https://github.com/ilyagr/diffedit3/releases). |
| 1191 |
|
| 1192 |
`Meld` is a graphical application that is recommended, but can be difficult to |
| 1193 |
install in some situations. `diffedit3` is designed to be easy to install and to |
| 1194 |
be usable in environments where Meld is difficult to use (e.g. over SSH via port |
| 1195 |
forwarding). `diffedit3` starts a local server that can be accessed via a web |
| 1196 |
browser, similarly to [Jupyter](https://jupyter.org/). |
| 1197 |
|
| 1198 |
There is also the `diffedit3-ssh` which is similar to `diffedit3` but does not |
| 1199 |
try to open the web browser pointing to the local server (the URL |
| 1200 |
printed to the terminal) automatically. `diffedit3-ssh` also always uses ports in between |
| 1201 |
17376-17380 and fails if they are all busy. This can be useful when working |
| 1202 |
over SSH. Open the fold below for more details of how to set that up. |
| 1203 |
|
| 1204 |
<details> |
| 1205 |
<summary> Tips for using `diffedit3-ssh` over SSH </summary> |
| 1206 |
|
| 1207 |
To use `diffedit3` over SSH, you need to set up port forwarding. One way to do |
| 1208 |
this is to start SSH as follows (copy-paste the relevant lines): |
| 1209 |
|
| 1210 |
```shell |
| 1211 |
ssh -L 17376:localhost:17376 \ |
| 1212 |
-L 17377:localhost:17377 \ |
| 1213 |
-L 17378:localhost:17378 \ |
| 1214 |
-L 17379:localhost:17379 \ |
| 1215 |
-L 17380:localhost:17380 \ |
| 1216 |
myhost.example.com |
| 1217 |
``` |
| 1218 |
|
| 1219 |
`diffedit3-ssh` is set up to use these 5 ports by default. Usually, only the |
| 1220 |
first of them will be used. The rest are used if another program happens to use |
| 1221 |
one of them, or if you run multiple instances of `diffedit3` at the same time. |
| 1222 |
|
| 1223 |
Another way is to add a snippet to `~/.ssh/config`: |
| 1224 |
|
| 1225 |
```ssh-config |
| 1226 |
Host myhost |
| 1227 |
User myself |
| 1228 |
Hostname myhost.example.com |
| 1229 |
LocalForward 17376 localhost:17376 |
| 1230 |
LocalForward 17377 localhost:17377 |
| 1231 |
LocalForward 17378 localhost:17378 |
| 1232 |
LocalForward 17379 localhost:17379 |
| 1233 |
LocalForward 17380 localhost:17380 |
| 1234 |
``` |
| 1235 |
|
| 1236 |
With that configuration, you should be able to simply `ssh myhost`. |
| 1237 |
|
| 1238 |
</details> |
| 1239 |
|
| 1240 |
Setting either `ui.diff-editor = "meld-3"` or `ui.diff-editor = "diffedit3"` |
| 1241 |
will result in the diff editor showing 3 panes: the diff on the left and right, |
| 1242 |
and an editing pane in the middle. This allow you to see both sides of the |
| 1243 |
original diff while editing. |
| 1244 |
|
| 1245 |
If you use `ui.diff-editor = "meld-3"`, note that you can still get the 2-pane |
| 1246 |
Meld view using `jj diff --tool meld`. `diffedit3` has a button you can use to |
| 1247 |
switch to a 2-pane view. |
| 1248 |
|
| 1249 |
To configure other diff editors in this way, you can include `$output` together |
| 1250 |
with `$left` and `$right` in `merge-tools.TOOL.edit-args`. `jj` will replace |
| 1251 |
`$output` with the directory where the diff editor will be expected to put the |
| 1252 |
result of the user's edits. Initially, the contents of `$output` will be the |
| 1253 |
same as the contents of `$right`. |
| 1254 |
|
| 1255 |
### `JJ-INSTRUCTIONS` |
| 1256 |
|
| 1257 |
When editing a diff, jj will include a synthetic file called `JJ-INSTRUCTIONS` |
| 1258 |
in the diff with instructions on how to edit the diff. Any changes you make to |
| 1259 |
this file will be ignored. To suppress the creation of this file, set |
| 1260 |
`ui.diff-instructions = false`. |
| 1261 |
|
| 1262 |
### Using Meld as a diff editor |
| 1263 |
|
| 1264 |
[Meld](https://meldmerge.org) is a nice and polished free diff editor. It can be |
| 1265 |
obtained as follows: |
| 1266 |
|
| 1267 |
- **Linux:** use your favorite package manager, e.g. `sudo apt install meld`. |
| 1268 |
|
| 1269 |
- **Windows:** Meld can be downloaded from <https://meldmerge.org/>. |
| 1270 |
|
| 1271 |
- **Mac OS:** Install Homebrew and run `brew install --cask meld`. |
| 1272 |
This will install both an app in `/Applications/Meld.app` and the command-line |
| 1273 |
`meld` command that `jj` uses. You can read about [more details and other |
| 1274 |
options](https://gist.github.com/ilyagr/1b40f6061d8ad320cee4c12843df1a23) but, |
| 1275 |
as of this writing, this is by far the easiest. |
| 1276 |
|
| 1277 |
`jj` has two diff editing configurations that use Meld: `meld` for a 2-pane view |
| 1278 |
and `meld-3` for a [three-pane view](#experimental-3-pane-diff-editing). |
| 1279 |
|
| 1280 |
There is also a `meld` [merge tool](#3-way-merge-tools-for-conflict-resolution) |
| 1281 |
that can be useful, but does not support displaying the merge base while |
| 1282 |
merging. |
| 1283 |
|
| 1284 |
### Using Vim as a diff editor |
| 1285 |
|
| 1286 |
Using `ui.diff-editor = "vimdiff"` is possible but not recommended. For a better |
| 1287 |
experience, you can follow [instructions from the Wiki] to configure the |
| 1288 |
[DirDiff Vim plugin] and/or the [vimtabdiff Python script]. |
| 1289 |
|
| 1290 |
[instructions from the Wiki]: https://github.com/jj-vcs/jj/wiki/Vim,-Neovim#using-vim-as-a-diff-tool |
| 1291 |
|
| 1292 |
[DirDiff Vim plugin]: https://github.com/will133/vim-dirdiff |
| 1293 |
[vimtabdiff Python script]: https://github.com/balki/vimtabdiff |
| 1294 |
|
| 1295 |
## 3-way merge tools for conflict resolution |
| 1296 |
|
| 1297 |
The `ui.merge-editor` key specifies the tool used for three-way merge tools |
| 1298 |
by `jj resolve`. For example: |
| 1299 |
|
| 1300 |
```toml |
| 1301 |
[ui] |
| 1302 |
# Use merge-tools.meld.merge-args |
| 1303 |
merge-editor = "meld" # Or "vscode" or "vscodium" or "kdiff3" or "vimdiff" |
| 1304 |
# Specify merge-args inline |
| 1305 |
merge-editor = ["meld", "$left", "$base", "$right", "-o", "$output"] |
| 1306 |
``` |
| 1307 |
|
| 1308 |
The following tools can be used out of the box, as long as they are installed: |
| 1309 |
- "kdiff3" |
| 1310 |
- "meld" |
| 1311 |
- "mergiraf" |
| 1312 |
- "smerge" |
| 1313 |
- "vimdiff" |
| 1314 |
- "vscode" |
| 1315 |
- "vscodium" |
| 1316 |
|
| 1317 |
Using VS Code as a merge tool works well with VS Code's [Remote |
| 1318 |
Development](https://code.visualstudio.com/docs/remote/remote-overview) |
| 1319 |
functionality, as long as `jj` is called from VS Code's terminal. |
| 1320 |
|
| 1321 |
### Setting up a custom merge tool |
| 1322 |
|
| 1323 |
To use a different tool named `TOOL`, the arguments to pass to the tool MUST be |
| 1324 |
specified either inline or in the `merge-tools.TOOL.merge-args` key. As an |
| 1325 |
example of how to set this key and other tool configuration options, here is |
| 1326 |
the out-of-the-box configuration of the three default tools. (There is no need |
| 1327 |
to copy it to your config file verbatim, but you are welcome to customize it.) |
| 1328 |
|
| 1329 |
```toml |
| 1330 |
[merge-tools.kdiff3] |
| 1331 |
# program = "kdiff3" # Defaults to the name of the tool if not specified |
| 1332 |
merge-args = ["$base", "$left", "$right", "-o", "$output", "--auto"] |
| 1333 |
[merge-tools.meld] |
| 1334 |
merge-args = ["$left", "$base", "$right", "-o", "$output", "--auto-merge"] |
| 1335 |
|
| 1336 |
[merge-tools.vimdiff] |
| 1337 |
merge-args = ["-f", "-d", "$output", "-M", |
| 1338 |
"$left", "$base", "$right", |
| 1339 |
"-c", "wincmd J", "-c", "set modifiable", |
| 1340 |
"-c", "set write"] |
| 1341 |
program = "vim" |
| 1342 |
merge-tool-edits-conflict-markers = true # See below for an explanation |
| 1343 |
``` |
| 1344 |
|
| 1345 |
`jj` makes the following substitutions: |
| 1346 |
|
| 1347 |
- `$output` (REQUIRED) is replaced with the name of the file that the merge tool |
| 1348 |
should output. `jj` will read this file after the merge tool exits. |
| 1349 |
|
| 1350 |
- `$left` and `$right` are replaced with the paths to two files containing the |
| 1351 |
content of each side of the conflict. |
| 1352 |
|
| 1353 |
- `$base` is replaced with the path to a file containing the contents of the |
| 1354 |
conflicted file in the last common ancestor of the two sides of the conflict. |
| 1355 |
|
| 1356 |
- `$marker_length` is replaced with the length of the conflict markers which |
| 1357 |
should be used for the file. This can be useful if the merge tool parses |
| 1358 |
and/or generates conflict markers. Usually, `jj` uses conflict markers of |
| 1359 |
length 7, but they can be longer if necessary to make parsing unambiguous. |
| 1360 |
|
| 1361 |
- `$path` is replaced with the path in the repository at which the file |
| 1362 |
will be eventually stored. It is relative to the root directory of the |
| 1363 |
repository and uses `/` as separators. |
| 1364 |
|
| 1365 |
Unlike `diff-args` or `edit-args`, there is no default value for `merge-args`. |
| 1366 |
If `merge-args` are not specified, the tool cannot be used for conflict |
| 1367 |
resolution. |
| 1368 |
|
| 1369 |
### Editing conflict markers with a tool or a text editor |
| 1370 |
|
| 1371 |
By default, the merge tool starts with an empty output file. If the tool puts |
| 1372 |
anything into the output file and exits with the 0 exit code, |
| 1373 |
`jj` assumes that the conflict is fully resolved, while if the tool exits with |
| 1374 |
a non-zero exit code, `jj` assumes that the merge should be canceled. |
| 1375 |
This is appropriate for most graphical merge tools. |
| 1376 |
|
| 1377 |
For merge tools which try to automatically resolve conflicts without user input, |
| 1378 |
this behavior may not be desired. For instance, some automatic merge tools use |
| 1379 |
an exit code of 1 to indicate that some conflicts were unable to be resolved and |
| 1380 |
that the output file should contain conflict markers. In that case, you could |
| 1381 |
set the config option `merge-tools.TOOL.merge-conflict-exit-codes = [1]` to tell |
| 1382 |
`jj` to expect conflict markers in the output file if the exit code is 1. If a |
| 1383 |
merge tool produces output using Git's "diff3" conflict style, `jj` should be |
| 1384 |
able to parse it correctly, so many Git merge drivers should be usable with `jj` |
| 1385 |
as well. |
| 1386 |
|
| 1387 |
Some tools (e.g. `vimdiff`) can present a multi-way diff but don't resolve |
| 1388 |
conflict themselves. When using such tools, `jj` |
| 1389 |
can help you by populating the output file with conflict markers before starting |
| 1390 |
the merge tool (instead of leaving the output file empty and letting the merge |
| 1391 |
tool fill it in). To do that, set the |
| 1392 |
`merge-tools.vimdiff.merge-tool-edits-conflict-markers = true` option. |
| 1393 |
|
| 1394 |
With this option set, if the output file still contains conflict markers after |
| 1395 |
the conflict is done, `jj` assumes that the conflict was only partially resolved |
| 1396 |
and parses the conflict markers to get the new state of the conflict. The |
| 1397 |
conflict is considered fully resolved when there are no conflict markers left. |
| 1398 |
The conflict marker style can also be customized per tool using the |
| 1399 |
`merge-tools.TOOL.conflict-marker-style` option, which takes the same values as |
| 1400 |
[`ui.conflict-marker-style`](#conflict-marker-style). |
| 1401 |
|
| 1402 |
## Code formatting and other file content transformations |
| 1403 |
|
| 1404 |
The `jj fix` command allows you to efficiently rewrite files in complex commit |
| 1405 |
graphs with no risk of introducing conflicts, using tools like `clang-format` or |
| 1406 |
`prettier`. The tools run as subprocesses that take a file content on standard |
| 1407 |
input and repeat it, with any desired changes, on standard output. |
| 1408 |
|
| 1409 |
This enables the command to format many versions of the same file concurrently |
| 1410 |
and without touching on the working copy. The local files are not and must not |
| 1411 |
be used. |
| 1412 |
|
| 1413 |
The file is only rewritten if the subprocess produces a successful exit code. |
| 1414 |
|
| 1415 |
### Configuration |
| 1416 |
|
| 1417 |
Tools are defined in a table where the keys are arbitrary identifiers and |
| 1418 |
the values have the following properties: |
| 1419 |
- `command`: The arguments used to run the tool. The first argument is the |
| 1420 |
path to an executable file. Arguments can contain these variables that will |
| 1421 |
be replaced: |
| 1422 |
- `$root` will be replaced with the workspace root path (the directory |
| 1423 |
containing the .jj directory). |
| 1424 |
- `$path` will be replaced with the repo-relative path of the file being |
| 1425 |
fixed. It is useful to provide the path to tools that include the path |
| 1426 |
in error messages, or behave differently based on the directory or file |
| 1427 |
name. |
| 1428 |
- `patterns`: List of filesets (see: `jj help -k filesets`), determining |
| 1429 |
which files the tool will affect based on their path. If this list is |
| 1430 |
empty, no files will be affected by the tool. If there are multiple |
| 1431 |
patterns, the tool is applied only once to each file in the union of the |
| 1432 |
patterns. |
| 1433 |
- `enabled`: Enables or disables the tool. If omitted, the tool is enabled. |
| 1434 |
This is useful for defining disabled tools in user configuration that can |
| 1435 |
be enabled in individual repositories with one config setting. |
| 1436 |
- `line-range-arg`: An optional template string specifying how to pass a line |
| 1437 |
range to the tool. It may include the variables `$first` and `$last`, which |
| 1438 |
will be replaced with the 1-based line numbers of, respectively, the first |
| 1439 |
and last lines inside the modified range. A range containing a single line |
| 1440 |
will have equal values for `$first` and `$last`. Empty ranges representing |
| 1441 |
deletions will be skipped because they cannot be represented this way. |
| 1442 |
If the tool does not support formatting specific line ranges, this setting |
| 1443 |
should be omitted, and the tool will always process the entire file. |
| 1444 |
Example: `line-range-arg = "--lines=$first:$last"`. |
| 1445 |
- `run-tool-if-zero-line-ranges`: Whether to run the tool invocation for this tool on |
| 1446 |
files that had zero line ranges to format in the revision being fixed. |
| 1447 |
Defaults to `false`, meaning the tool is skipped for these files. This default |
| 1448 |
behavior serves two main purposes: |
| 1449 |
- Avoiding unnecessary executions of tools when no line ranges are modified. |
| 1450 |
- Preventing tools configured with `line-range-arg` from making overly |
| 1451 |
broad changes (formatting the whole file) when no line ranges are available. |
| 1452 |
|
| 1453 |
Setting this to `true` is useful if the tool should run regardless of diffs |
| 1454 |
(e.g., to sort imports, or run with `--include-unchanged-files`). |
| 1455 |
|
| 1456 |
`jj fix` provides the file content anonymously on standard input, but the name |
| 1457 |
of the file being formatted may be important for include sorting or other output |
| 1458 |
like error messages. To address this, you can use the `$root` and `$path` in |
| 1459 |
your arguments. |
| 1460 |
|
| 1461 |
### Enforce coding style rules |
| 1462 |
|
| 1463 |
Suppose you want to use `clang-format` to format your `*.c` and `*.h` files, |
| 1464 |
as well as sorting their `#include` directives. |
| 1465 |
|
| 1466 |
```toml |
| 1467 |
[fix.tools.clang-format] |
| 1468 |
command = ["/usr/bin/clang-format", "--sort-includes", "--assume-filename=$path"] |
| 1469 |
patterns = ["glob:'**/*.c'", |
| 1470 |
"glob:'**/*.h'"] |
| 1471 |
``` |
| 1472 |
|
| 1473 |
### Sort and remove duplicate lines from a file |
| 1474 |
|
| 1475 |
`jj fix` can also be used with tools that are not considered code formatters. |
| 1476 |
|
| 1477 |
Suppose you have a list of words in a text file in your repository, and you want |
| 1478 |
to keep the file sorted alphabetically and remove any duplicate words. |
| 1479 |
|
| 1480 |
```toml |
| 1481 |
[fix.tools.sort-word-list] |
| 1482 |
command = ["sort", "-u"] |
| 1483 |
patterns = ["word_list.txt"] |
| 1484 |
``` |
| 1485 |
|
| 1486 |
### Enforce code formatting on modified lines |
| 1487 |
|
| 1488 |
You can configure `jj fix` to run a formatter only on the modified lines of a |
| 1489 |
file, rather than formatting the entire file. This is particularly useful for |
| 1490 |
avoiding unrelated formatting changes in untouched parts of a file. |
| 1491 |
|
| 1492 |
To enable this, specify the `line-range-arg` configuration to match the line |
| 1493 |
range argument format expected by your tool. The formatter will be invoked with |
| 1494 |
this argument repeated for each modified line range (e.g. `--lines=10-20 |
| 1495 |
--lines=30-40`). |
| 1496 |
|
| 1497 |
Additionally, you can use `run-tool-if-zero-line-ranges` to control the |
| 1498 |
behavior when a diff results in zero line ranges (which can happen when lines |
| 1499 |
are only deleted or with `--include-unchanged-files`). If `false` (the default), |
| 1500 |
`jj` will skip the tool entirely for that file. If `true`, `jj` will run the tool |
| 1501 |
even when there are zero line ranges calculated. This is useful for tools that |
| 1502 |
perform file-wide operations, such as import sorting. |
| 1503 |
|
| 1504 |
Note that you can use the `--all-lines` CLI flag for `jj fix` to ignore these |
| 1505 |
line ranges and format the entire modified file instead. |
| 1506 |
|
| 1507 |
Example of `clang-format` with line ranges: |
| 1508 |
|
| 1509 |
```toml |
| 1510 |
[fix.tools.clang-format] |
| 1511 |
command = ["/usr/bin/clang-format", "--assume-filename=$path"] |
| 1512 |
patterns = ["glob:'**/*.cc'", |
| 1513 |
"glob:'**/*.h'"] |
| 1514 |
enabled = true |
| 1515 |
line-range-arg = "--lines=$first:$last" |
| 1516 |
run-tool-if-zero-line-ranges = false |
| 1517 |
``` |
| 1518 |
|
| 1519 |
### Tools stored inside the workspace |
| 1520 |
|
| 1521 |
Some fix tools may be stored inside the workspace. For example, a binary may be |
| 1522 |
stored inside `node_modules`. Use the `$root` variable to create an absolute |
| 1523 |
path to such a program: |
| 1524 |
|
| 1525 |
```toml |
| 1526 |
[fix.tools.biome] |
| 1527 |
command = ["$root/node_modules/@biomejs/biome/bin/biome", "format", "--stdin-file-path=$path"] |
| 1528 |
patterns = ["glob:'**/*.ts'", "glob:'**/*.tsx'"] |
| 1529 |
``` |
| 1530 |
|
| 1531 |
### Execution order of tools |
| 1532 |
|
| 1533 |
If two or more tools affect the same file, they are executed in the ascending |
| 1534 |
lexicographical order of their configured names. Any tool, but the first one to |
| 1535 |
be executed, get as input the content of the file produced by the previous |
| 1536 |
tool. This will remain as a tie breaker if other ordering mechanisms are |
| 1537 |
introduced in the future. |
| 1538 |
|
| 1539 |
If you use numbers in tool names to control execution order, remember to |
| 1540 |
include enough leading zeros so that, for example, `09` sorts before `10`. |
| 1541 |
|
| 1542 |
Suppose you want to keep only the 10 smallest numbers in a text file that |
| 1543 |
contains one number on each line. This can be accomplished with `sort` and |
| 1544 |
`head`, but execution order is important. |
| 1545 |
|
| 1546 |
```toml |
| 1547 |
[fix.tools.1-sort-numbers-file] |
| 1548 |
command = ["sort", "-n"] |
| 1549 |
patterns = ["numbers.txt"] |
| 1550 |
|
| 1551 |
[fix.tools.2-truncate-numbers-file] |
| 1552 |
command = ["head", "-n", "10"] |
| 1553 |
patterns = ["numbers.txt"] |
| 1554 |
``` |
| 1555 |
|
| 1556 |
### Disabling and enabling tools |
| 1557 |
|
| 1558 |
Tools can be disabled and enabled with the optional `enabled` config. This |
| 1559 |
allows you to define tools globally but enable them only for specific |
| 1560 |
repositories. |
| 1561 |
|
| 1562 |
In the user configuration, define a disabled tool for running rustfmt: |
| 1563 |
|
| 1564 |
```toml |
| 1565 |
[fix.tools.rustfmt] |
| 1566 |
enabled = false |
| 1567 |
command = ["rustfmt", "--emit", "stdout"] |
| 1568 |
patterns = ["glob:'**/*.rs'"] |
| 1569 |
``` |
| 1570 |
|
| 1571 |
Then to use the tool in a specific repository, set the `enabled` config: |
| 1572 |
|
| 1573 |
```shell |
| 1574 |
$ jj config set --repo fix.tools.rustfmt.enabled true |
| 1575 |
``` |
| 1576 |
|
| 1577 |
## `run`: Running commands across revisions {: #run } |
| 1578 |
|
| 1579 |
The `jj run` command executes a command against each revision in a set, |
| 1580 |
checking out each one into an isolated working copy, running the command, and |
| 1581 |
amending the revision with any resulting changes. |
| 1582 |
|
| 1583 |
### `run.jobs`: Default parallelism {: #run.jobs } |
| 1584 |
|
| 1585 |
By default `jj run` processes one revision at a time. You can increase |
| 1586 |
parallelism with the `run.jobs` setting: |
| 1587 |
|
| 1588 |
```toml |
| 1589 |
[run] |
| 1590 |
jobs = 8 |
| 1591 |
``` |
| 1592 |
|
| 1593 |
The value must be a positive integer. The `--jobs` / `-j` CLI flag overrides |
| 1594 |
this setting for a single invocation: |
| 1595 |
|
| 1596 |
```shell |
| 1597 |
jj run -j 4 -- cargo fmt |
| 1598 |
``` |
| 1599 |
|
| 1600 |
## Commit Signing |
| 1601 |
|
| 1602 |
`jj` can be configured to sign and verify the commits it creates using either |
| 1603 |
GnuPG or SSH signing keys. |
| 1604 |
|
| 1605 |
To do this you need to configure a signing backend. |
| 1606 |
|
| 1607 |
Setting the backend to `"none"` disables signing. |
| 1608 |
|
| 1609 |
### GnuPG Signing |
| 1610 |
|
| 1611 |
```toml |
| 1612 |
[signing] |
| 1613 |
behavior = "own" |
| 1614 |
backend = "gpg" |
| 1615 |
## You can set `key` to anything accepted by `gpg -u` |
| 1616 |
## If not set then defaults to the key associated with `user.email` |
| 1617 |
# key = "4ED556E9729E000F" |
| 1618 |
# key = "[email protected]" |
| 1619 |
``` |
| 1620 |
|
| 1621 |
By default the gpg backend will look for a `gpg` binary on your path. If you want |
| 1622 |
to change the program used or specify a path to `gpg` explicitly you can set: |
| 1623 |
|
| 1624 |
```toml |
| 1625 |
[signing] |
| 1626 |
backends.gpg.program = "gpg2" |
| 1627 |
``` |
| 1628 |
|
| 1629 |
Also by default the gpg backend will consider key expiry when verifying commit signatures. |
| 1630 |
To consider expired keys as valid you can set: |
| 1631 |
|
| 1632 |
```toml |
| 1633 |
[signing] |
| 1634 |
backends.gpg.allow-expired-keys = true |
| 1635 |
``` |
| 1636 |
|
| 1637 |
#### PKCS#12 Certificates |
| 1638 |
|
| 1639 |
PKCS#12 certificates can be used to sign commits using the `gpgsm` backend. |
| 1640 |
|
| 1641 |
```toml |
| 1642 |
[signing] |
| 1643 |
behavior = "own" |
| 1644 |
backend = "gpgsm" |
| 1645 |
## You can set `key` to anything accepted by `gpgsm -u` |
| 1646 |
## If not set then defaults to the key associated with `user.email` |
| 1647 |
# key = "4ED556E9729E000F" |
| 1648 |
# key = "[email protected]" |
| 1649 |
``` |
| 1650 |
|
| 1651 |
By default the gpgsm backend will look for a `gpgsm` binary on your path. If you want |
| 1652 |
to change the program used or specify a path to `gpgsm` explicitly you can set: |
| 1653 |
|
| 1654 |
```toml |
| 1655 |
[signing] |
| 1656 |
backends.gpgsm.program = "gpgsm" |
| 1657 |
``` |
| 1658 |
|
| 1659 |
Also by default the gpgsm backend will consider key expiry when verifying commit signatures. |
| 1660 |
To consider expired keys as valid you can set: |
| 1661 |
|
| 1662 |
```toml |
| 1663 |
[signing] |
| 1664 |
backends.gpgsm.allow-expired-keys = true |
| 1665 |
``` |
| 1666 |
|
| 1667 |
### SSH Signing |
| 1668 |
|
| 1669 |
```toml |
| 1670 |
[signing] |
| 1671 |
behavior = "own" |
| 1672 |
backend = "ssh" |
| 1673 |
key = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIGj+J6N6SO+4P8dOZqfR1oiay2yxhhHnagH52avUqw5h" |
| 1674 |
## You can also use a path instead of embedding the key |
| 1675 |
# key = "~/.ssh/id_for_signing.pub" |
| 1676 |
``` |
| 1677 |
|
| 1678 |
By default the ssh backend will look for a `ssh-keygen` binary on your path. If you want |
| 1679 |
to change the program used or specify a path to `ssh-keygen` explicitly you can set: |
| 1680 |
|
| 1681 |
```toml |
| 1682 |
[signing] |
| 1683 |
backends.ssh.program = "/path/to/ssh-keygen" |
| 1684 |
``` |
| 1685 |
|
| 1686 |
When verifying commit signatures the ssh backend needs to be provided with an allowed-signers |
| 1687 |
file containing the public keys of authors whose signatures you want to be able to verify. |
| 1688 |
|
| 1689 |
You can find the format for this file in the |
| 1690 |
[ssh-keygen man page](https://man.openbsd.org/ssh-keygen#ALLOWED_SIGNERS). This can be provided |
| 1691 |
as follows: |
| 1692 |
|
| 1693 |
```toml |
| 1694 |
[signing] |
| 1695 |
backends.ssh.allowed-signers = "/path/to/allowed-signers" |
| 1696 |
``` |
| 1697 |
|
| 1698 |
Additionally, an SSH KRL or list of revoked public keys (see |
| 1699 |
[ssh-keygen man page](https://man.openbsd.org/ssh-keygen#KEY_REVOCATION_LISTS)) can be provided |
| 1700 |
with the `revocation-list` option. If a public key is found in this file then any signature |
| 1701 |
relating to it is marked as invalid. |
| 1702 |
|
| 1703 |
```toml |
| 1704 |
[signing] |
| 1705 |
backends.ssh.revocation-list = "/path/to/revocation-list" |
| 1706 |
``` |
| 1707 |
|
| 1708 |
### Manually signing commits |
| 1709 |
|
| 1710 |
You can use [`jj sign`](./cli-reference.md#jj-sign)/[`jj unsign`](./cli-reference.md#jj-unsign) |
| 1711 |
to sign/unsign commits manually. |
| 1712 |
|
| 1713 |
!!! warning |
| 1714 |
|
| 1715 |
`jj sign` always signs commits, even if they are already signed by the |
| 1716 |
user. While this is cumbersome for users signing via hardware devices, we |
| 1717 |
cannot reliably check if a commit is already signed without creating a |
| 1718 |
signature (see [this issue](https://github.com/jj-vcs/jj/issues/5786)). |
| 1719 |
|
| 1720 |
### Automatically signing commits |
| 1721 |
|
| 1722 |
The `signing.behavior` configuration option has four different options for what |
| 1723 |
to do with signing commits on modification of a change (e.g., rebasing or edits). |
| 1724 |
|
| 1725 |
- `drop`: do not automatically sign; if a change was signed before |
| 1726 |
modification, drop that signing after modification. |
| 1727 |
- `keep`: if a change was signed before modification, and it was authored by |
| 1728 |
you, attempt to sign it again after the modification. |
| 1729 |
- `own`: sign all commits that were authored by you when you modify them. |
| 1730 |
- `force`: sign all commits after modification, always, even if you are not the |
| 1731 |
author. |
| 1732 |
|
| 1733 |
Instead of signing all commits during creation when `signing.behavior` is |
| 1734 |
set to `own`, the `git.sign-on-push` configuration can be used to sign |
| 1735 |
commits only upon running `jj git push`. All mutable unsigned commits |
| 1736 |
being pushed will be signed prior to pushing. This might be preferred if the |
| 1737 |
signing backend requires user interaction or is slow, so that signing is |
| 1738 |
performed in a single batch operation. |
| 1739 |
|
| 1740 |
```toml |
| 1741 |
# Configure signing backend as before, but lazily signing only on push. |
| 1742 |
[signing] |
| 1743 |
behavior = "drop" |
| 1744 |
backend = "ssh" |
| 1745 |
key = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIGj+J6N6SO+4P8dOZqfR1oiay2yxhhHnagH52avUqw5h" |
| 1746 |
|
| 1747 |
[git] |
| 1748 |
sign-on-push = true |
| 1749 |
``` |
| 1750 |
|
| 1751 |
## Commit Signature Verification |
| 1752 |
|
| 1753 |
By default signature verification and display is **disabled** as it incurs a |
| 1754 |
performance cost when rendering medium to large change logs. You can enable it |
| 1755 |
by setting `ui.show-cryptographic-signatures` to true in your configuration. |
| 1756 |
|
| 1757 |
If you want to display commit signatures in your templates, you can use |
| 1758 |
`commit.signature()` (see [Commit type](./templates.md#commit-type)). The |
| 1759 |
returned [CryptographicSignature |
| 1760 |
Type](./templates.md#cryptographicsignature-type) provides methods to retrieve |
| 1761 |
signature details. |
| 1762 |
|
| 1763 |
## Git settings |
| 1764 |
|
| 1765 |
### Default colocation |
| 1766 |
|
| 1767 |
When creating a Git-backed Jujutsu repository, they use "colocated" mode by |
| 1768 |
default, which places the `.git` directory next to the `.jj` directory. |
| 1769 |
Colocation allows some amount of two-way interoperability, but it can perform |
| 1770 |
worse in large repos. |
| 1771 |
|
| 1772 |
The setting `git.colocate` is a boolean option that controls whether or not the |
| 1773 |
`jj git init` and `jj git clone` commands should create colocated workspace by |
| 1774 |
default. Set `git.colocate` to `false` to disable it. |
| 1775 |
|
| 1776 |
See [Colocated Jujutsu/Git workspaces](git-compatibility.md#colocated-jujutsugit-repos) |
| 1777 |
for more information. |
| 1778 |
|
| 1779 |
### Default object hash format |
| 1780 |
|
| 1781 |
Traditionally, Git used the SHA-1 hash function to compute the identifiers for |
| 1782 |
[objects]. Because SHA-1 is not considered cryptographically secure anymore, Git |
| 1783 |
is in the [process of transitioning][transition] to a stronger hash function, |
| 1784 |
namely SHA-256. |
| 1785 |
|
| 1786 |
Currently, the object hash function can only be set when initializing a new Git |
| 1787 |
repository. The setting `git.object-hash` controls the default choice for that |
| 1788 |
purpose. It can take the values `sha1` (default) and `sha256`. |
| 1789 |
|
| 1790 |
Note that at the moment there is no interopability between the formats, and not |
| 1791 |
all code forges support SHA-256 repositories yet. |
| 1792 |
|
| 1793 |
[objects]: https://git-scm.com/book/en/v2/Git-Internals-Git-Objects |
| 1794 |
[transition]: https://git-scm.com/docs/hash-function-transition |
| 1795 |
|
| 1796 |
### Default remotes for `jj git fetch` and `jj git push` |
| 1797 |
|
| 1798 |
By default, if a single remote exists it is used for `jj git fetch` and `jj git |
| 1799 |
push`; however if multiple remotes exist, the default remote is assumed to be |
| 1800 |
named `"origin"`, just like in Git. Sometimes this is undesirable, e.g. when you |
| 1801 |
want to fetch from a different remote than you push to, such as a GitHub fork. |
| 1802 |
|
| 1803 |
To change this behavior, you can modify the [repository |
| 1804 |
configuration](#config-files-and-toml) variable `git.fetch`, which can be a |
| 1805 |
single remote, or a list of remotes to fetch from multiple places: |
| 1806 |
|
| 1807 |
```sh |
| 1808 |
jj config set --repo git.fetch "upstream" |
| 1809 |
jj config set --repo git.fetch '["origin", "upstream"]' |
| 1810 |
``` |
| 1811 |
|
| 1812 |
By default, the specified pattern matches remote names with glob syntax. You can |
| 1813 |
also use other [string pattern syntax](revsets.md#string-patterns): |
| 1814 |
|
| 1815 |
```sh |
| 1816 |
jj config set --repo git.fetch "regex:'^(remote|upstream)'" |
| 1817 |
jj config set --repo git.fetch '["remote*", "upstream*"]' |
| 1818 |
``` |
| 1819 |
|
| 1820 |
Similarly, you can also set the variable `git.push` to cause `jj git push` to |
| 1821 |
push to a different remote: |
| 1822 |
|
| 1823 |
```sh |
| 1824 |
jj config set --repo git.push "github" |
| 1825 |
``` |
| 1826 |
|
| 1827 |
Note that unlike `git.fetch`, `git.push` can currently only be a single remote. |
| 1828 |
This is not a hard limitation, and could be changed in the future if there is |
| 1829 |
demand. |
| 1830 |
|
| 1831 |
### Default bookmarks and tags to fetch |
| 1832 |
|
| 1833 |
You can configure which bookmarks and tags to fetch by default per remote, using |
| 1834 |
the `remotes.<name>.fetch-bookmarks`/`fetch-tags` config. The value is a [string |
| 1835 |
pattern](./revsets.md#string-patterns) that matches the names of the bookmarks |
| 1836 |
and tags to fetch. If `remotes.<name>.fetch-bookmarks` is not configured, the |
| 1837 |
default fetch refspecs for the remotes are read from the Git configuration. |
| 1838 |
|
| 1839 |
The glob pattern supports only `*` (other wildcard characters like `?` are *not* |
| 1840 |
supported). You can combine patterns with logical operators to specify multiple |
| 1841 |
bookmarks and tags, but only union and negative intersection are supported. |
| 1842 |
|
| 1843 |
```toml |
| 1844 |
[remotes.origin] |
| 1845 |
fetch-bookmarks = "~gh-pages" |
| 1846 |
fetch-tags = "v*" |
| 1847 |
``` |
| 1848 |
|
| 1849 |
### Automatic tracking of bookmarks |
| 1850 |
|
| 1851 |
You can configure which bookmarks to track automatically per remote, using the |
| 1852 |
`remotes.<name>.auto-track-bookmarks` config. The value is a |
| 1853 |
[string pattern](./revsets.md#string-patterns) that matches the names of the |
| 1854 |
bookmarks to track. This setting is applied to all new bookmarks, including ones |
| 1855 |
created locally and ones fetched from the remote. For example: |
| 1856 |
|
| 1857 |
```toml |
| 1858 |
[remotes.origin] |
| 1859 |
auto-track-bookmarks = "*" |
| 1860 |
``` |
| 1861 |
|
| 1862 |
This will simply track all bookmarks for the remote "origin". There are various |
| 1863 |
reasons to restrict which bookmarks to track: |
| 1864 |
|
| 1865 |
- When collaborating with other people via the same remote, you may not want to |
| 1866 |
track all the bookmarks of your collaborators. Similarly, you may not want to |
| 1867 |
push some of your bookmarks to the remote at all; these may only be intended |
| 1868 |
for local use. Many people use a "personal prefix" in their bookmark names. |
| 1869 |
This marks a bookmark as belonging to one person, making it possible to track |
| 1870 |
and push only bookmarks with that prefix. For example, Alice may set her |
| 1871 |
configuration like so: |
| 1872 |
|
| 1873 |
```toml |
| 1874 |
[remotes.origin] |
| 1875 |
auto-track-bookmarks = "alice/*" |
| 1876 |
``` |
| 1877 |
|
| 1878 |
That way, bookmarks pushed by other people (who probably use a different |
| 1879 |
prefix or none at all) are not tracked automatically. At the same time, Alice |
| 1880 |
can create bookmarks without the prefix for local-only use. You can also |
| 1881 |
configure Jujutsu to use your prefix for generated bookmark names; see the |
| 1882 |
section |
| 1883 |
["Generated bookmark names on push"](#generated-bookmark-names-on-push). |
| 1884 |
|
| 1885 |
- Another reason to restrict the bookmarks to track may be that you're not |
| 1886 |
collaborating with people using the same remote, but a different one. For |
| 1887 |
example, if you make a fork on GitHub, your fork will usually be called |
| 1888 |
"origin", while the repository you forked from is usually called "upstream". |
| 1889 |
In that case, you may want to track all bookmarks from your fork, but only the |
| 1890 |
"main" bookmark from upstream. Here's an example how to achieve that: |
| 1891 |
|
| 1892 |
```toml |
| 1893 |
[remotes.origin] |
| 1894 |
auto-track-bookmarks = "*" |
| 1895 |
[remotes.upstream] |
| 1896 |
auto-track-bookmarks = "main" |
| 1897 |
``` |
| 1898 |
|
| 1899 |
- If you're collaborating with people on the same remote, but your bookmark |
| 1900 |
names don't follow a pattern that allows a bookmark's "owner" to be identified |
| 1901 |
(e.g. `alice/*`), you can use `auto-track-created-bookmarks` instead: |
| 1902 |
|
| 1903 |
```toml |
| 1904 |
[remotes.origin] |
| 1905 |
auto-track-created-bookmarks = "*" |
| 1906 |
``` |
| 1907 |
|
| 1908 |
This pattern will only apply to bookmarks you create with `jj bookmark create` |
| 1909 |
and `jj bookmark set`. The disadvantage of this option is the fact that you |
| 1910 |
will have to track your own bookmarks manually if you fetch them from the |
| 1911 |
remote. This may happen regularly if you use multiple computers to work on the |
| 1912 |
same project. |
| 1913 |
|
| 1914 |
- Lastly, you may be working on various projects with different conventions for |
| 1915 |
bookmark names. In that case, it can be handy to apply different configuration |
| 1916 |
to different (groups of) repositories. Read about how to do that in the |
| 1917 |
section ["Conditional variables"](#conditional-variables). |
| 1918 |
|
| 1919 |
### Automatic local bookmark creation on `jj git clone` |
| 1920 |
|
| 1921 |
When cloning a new Git repository, `jj` by default creates a local bookmark |
| 1922 |
tracking the default remote bookmark (such as `main` for `main@origin`.) If you |
| 1923 |
aren't going to update the `main` bookmark locally, the tracking bookmark isn't |
| 1924 |
necessary. |
| 1925 |
|
| 1926 |
This behavior can be disabled by |
| 1927 |
|
| 1928 |
```toml |
| 1929 |
[git] |
| 1930 |
track-default-bookmark-on-clone = false |
| 1931 |
``` |
| 1932 |
|
| 1933 |
### Abandon commits that became unreachable in Git |
| 1934 |
|
| 1935 |
By default, when `jj` imports refs from Git, it will look for commits that used |
| 1936 |
to be [reachable][reachable] but no longer are reachable. Those commits will |
| 1937 |
then be abandoned, and any descendant commits will be rebased off of them (as |
| 1938 |
usual when commits are abandoned). You can disable this behavior and instead |
| 1939 |
leave the Git-unreachable commits in your repo by setting: |
| 1940 |
|
| 1941 |
```toml |
| 1942 |
[git] |
| 1943 |
abandon-unreachable-commits = false |
| 1944 |
``` |
| 1945 |
|
| 1946 |
[reachable]: https://git-scm.com/docs/gitglossary/#Documentation/gitglossary.txt-aiddefreachableareachable |
| 1947 |
|
| 1948 |
### Replicating evolution history for fetched or imported Git commits |
| 1949 |
|
| 1950 |
By default, when `jj` imports commits from Git, it attempts to reconstruct their |
| 1951 |
evolution history using change IDs. If you are importing a large number of |
| 1952 |
commits, you can temporarily disable this behavior to improve performance: |
| 1953 |
|
| 1954 |
```toml |
| 1955 |
[git] |
| 1956 |
record-synthetic-predecessors = false |
| 1957 |
``` |
| 1958 |
|
| 1959 |
### Generated bookmark names on push |
| 1960 |
|
| 1961 |
`jj git push --change` generates bookmark names with a prefix of "push-" by |
| 1962 |
default. You can pick a different prefix and formatting by setting the |
| 1963 |
`templates.git_push_bookmark` template. For example: |
| 1964 |
|
| 1965 |
```toml |
| 1966 |
[templates] |
| 1967 |
git_push_bookmark = '"martinvonz/push-" ++ change_id.short()' |
| 1968 |
``` |
| 1969 |
|
| 1970 |
This template should include expressions like `change_id` to generate unique and |
| 1971 |
stable bookmark. |
| 1972 |
|
| 1973 |
### Set of private commits |
| 1974 |
|
| 1975 |
You can configure the set of private commits by setting `git.private-commits` to |
| 1976 |
a revset. The value is a revset of commits that Jujutsu will refuse to push. If |
| 1977 |
unset, all commits are eligible to be pushed. |
| 1978 |
|
| 1979 |
```toml |
| 1980 |
[git] |
| 1981 |
# Prevent pushing work in progress or anything explicitly labeled "private" |
| 1982 |
private-commits = "description('wip:*') | description('private:*')" |
| 1983 |
``` |
| 1984 |
|
| 1985 |
If a commit is in `git.private-commits` but is already on the remote, then it is |
| 1986 |
not considered a private commit. Commits that are immutable are also excluded |
| 1987 |
from the private set. |
| 1988 |
|
| 1989 |
Private commits prevent their descendants from being pushed, since doing so |
| 1990 |
would require pushing the private commit as well. |
| 1991 |
|
| 1992 |
### Git subprocessing behavior |
| 1993 |
|
| 1994 |
Git remote interactions are handled by spawning a `git` subprocess. |
| 1995 |
If `git` is not on your OS path, or you want to specify a particular binary, |
| 1996 |
you can: |
| 1997 |
|
| 1998 |
```toml |
| 1999 |
[git] |
| 2000 |
executable-path = "/path/to/git" |
| 2001 |
``` |
| 2002 |
|
| 2003 |
## Gerrit settings |
| 2004 |
|
| 2005 |
### Default remote |
| 2006 |
|
| 2007 |
To configure the default remote that `jj gerrit upload` will push to, set |
| 2008 |
`gerrit.default-remote`. This can be overridden with the `--remote` option. |
| 2009 |
|
| 2010 |
```toml |
| 2011 |
[gerrit] |
| 2012 |
default-remote = "gerrit" |
| 2013 |
``` |
| 2014 |
|
| 2015 |
### Default remote branch |
| 2016 |
|
| 2017 |
To configure the default branch that `jj gerrit upload` will push to, set |
| 2018 |
`gerrit.default-remote-branch`. This can be overridden with the |
| 2019 |
`--remote-branch` option. |
| 2020 |
|
| 2021 |
```toml |
| 2022 |
[gerrit] |
| 2023 |
default-remote-branch = "main" |
| 2024 |
``` |
| 2025 |
|
| 2026 |
### `Link` trailer |
| 2027 |
|
| 2028 |
Since version 3.3.1 Gerrit supports an alternative to the `Change-Id` trailer, |
| 2029 |
using a [`Link` trailer][Gerrit Link trailer] in the format of |
| 2030 |
`<review-url>/id/I<change-id>`. To have `jj gerrit upload` automatically add a |
| 2031 |
`Link` trailer instead of a `Change-Id` trailer, set `gerrit.review-url` to the |
| 2032 |
URL preview you'd like to use. |
| 2033 |
|
| 2034 |
```toml |
| 2035 |
[gerrit] |
| 2036 |
review-url = "https://review.gerrithub.io/your/project" |
| 2037 |
``` |
| 2038 |
|
| 2039 |
Note that if a `Change-Id` or `Link` trailer already exists in a change, then |
| 2040 |
`jj gerrit upload` will not add any trailer. |
| 2041 |
|
| 2042 |
[Gerrit Link trailer]: https://gerrit-documentation.storage.googleapis.com/Documentation/3.3.1/cmd-hook-commit-msg.html |
| 2043 |
|
| 2044 |
## Merge settings |
| 2045 |
|
| 2046 |
### Granularity of hunks |
| 2047 |
|
| 2048 |
`jj` by default resolves content conflicts by splitting text into line-level |
| 2049 |
hunks and merge them. This can be configured to split hunks further into |
| 2050 |
word-level hunks. |
| 2051 |
|
| 2052 |
* `line`: split into line hunks (default) |
| 2053 |
* `word`: split into word hunks |
| 2054 |
|
| 2055 |
```toml |
| 2056 |
[merge] |
| 2057 |
hunk-level = "line" |
| 2058 |
``` |
| 2059 |
|
| 2060 |
### Resolution of same-change conflicts |
| 2061 |
|
| 2062 |
`jj` by default resolves conflicts if all sides made the same change. This |
| 2063 |
matches what Git and Mercurial do (in the 3-way case at least), but not what |
| 2064 |
Darcs does. It also means that repeated 3-way merging of multiple trees may give |
| 2065 |
different results depending on the order of merging. To turn it off, set |
| 2066 |
`same-change = "keep"`. |
| 2067 |
|
| 2068 |
* `keep`: leave same-change conflict unresolved |
| 2069 |
* `accept`: resolve same-change conflict to new value (default) |
| 2070 |
|
| 2071 |
```toml |
| 2072 |
[merge] |
| 2073 |
same-change = "accept" |
| 2074 |
``` |
| 2075 |
|
| 2076 |
## Converge settings |
| 2077 |
|
| 2078 |
The `jj converge` command attempts to resolve divergence by replacing two or |
| 2079 |
more divergent commits with a single commit. The command accepts a |
| 2080 |
`--revisions REVSET` argument, and looks for divergence within the commits that |
| 2081 |
match that revset. The `--revisions` argument is optional. By default |
| 2082 |
`jj converge` uses the `revsets.converge` revset: |
| 2083 |
|
| 2084 |
```toml |
| 2085 |
[revsets] |
| 2086 |
converge = "mutable() & divergent()" |
| 2087 |
``` |
| 2088 |
|
| 2089 |
## Filesystem monitor |
| 2090 |
|
| 2091 |
In large repositories, it may be beneficial to use a "filesystem monitor" to |
| 2092 |
track changes to the working copy. This allows `jj` to take working copy |
| 2093 |
snapshots without having to rescan the entire working copy. |
| 2094 |
|
| 2095 |
This is governed by the `fsmonitor.backend` option. Currently, the valid values |
| 2096 |
are `"none"` or `"watchman"`. |
| 2097 |
|
| 2098 |
### Watchman |
| 2099 |
|
| 2100 |
To configure the Watchman filesystem monitor, set |
| 2101 |
`fsmonitor.backend = "watchman"`. Ensure that you have [installed the Watchman |
| 2102 |
executable on your system](https://facebook.github.io/watchman/docs/install). |
| 2103 |
|
| 2104 |
You can configure `jj` to use watchman triggers to automatically create |
| 2105 |
snapshots on filesystem changes by setting |
| 2106 |
`fsmonitor.watchman.register-snapshot-trigger = true`. |
| 2107 |
|
| 2108 |
A full configuration for watchman can look like this: |
| 2109 |
|
| 2110 |
```toml |
| 2111 |
[fsmonitor] |
| 2112 |
backend = "watchman" |
| 2113 |
|
| 2114 |
[fsmonitor.watchman] |
| 2115 |
register-snapshot-trigger = true |
| 2116 |
``` |
| 2117 |
|
| 2118 |
You can check whether Watchman is enabled and whether it is installed correctly |
| 2119 |
using `jj debug watchman status`. |
| 2120 |
|
| 2121 |
Note: `watchman` heavily uses `inotify` and sets up a user watch per-file. On |
| 2122 |
large repositories, this may cause `watchman` to fail and commands like |
| 2123 |
`jj status` to take longer than expected. If you experience this run |
| 2124 |
`jj debug watchman status` and tune your `inotify` limits. |
| 2125 |
|
| 2126 |
## Snapshot settings |
| 2127 |
|
| 2128 |
### Paths to automatically track |
| 2129 |
|
| 2130 |
All new files in the working copy that don't match the ignore patterns are |
| 2131 |
tracked by default. You can set the `snapshot.auto-track` to set which paths |
| 2132 |
get automatically tracked when they're added to the working copy. See the |
| 2133 |
[fileset documentation](filesets.md) for the syntax. Files with paths matching |
| 2134 |
[ignore files](working-copy.md#ignored-files) are never tracked automatically. |
| 2135 |
|
| 2136 |
If you set `snapshot.auto-track` to a non-default value, untracked files can be |
| 2137 |
tracked with `jj file track`. |
| 2138 |
|
| 2139 |
You can use `jj file untrack` to untrack a file while keeping it in the working |
| 2140 |
copy. However, first [ignore](working-copy.md#ignored-files) them or remove them |
| 2141 |
from the `snapshot.auto-track` patterns; otherwise they will be immediately |
| 2142 |
tracked again. |
| 2143 |
|
| 2144 |
### Maximum size for new files |
| 2145 |
|
| 2146 |
By default, as an anti-footgun measure, `jj` will refuse to add new files to the |
| 2147 |
snapshot that are larger than a certain size; the default is 1MiB. This can be |
| 2148 |
changed by setting `snapshot.max-new-file-size` to a different value. For |
| 2149 |
example: |
| 2150 |
|
| 2151 |
```toml |
| 2152 |
[snapshot] |
| 2153 |
max-new-file-size = "10MiB" |
| 2154 |
# the following is equivalent |
| 2155 |
max-new-file-size = 10485760 |
| 2156 |
``` |
| 2157 |
|
| 2158 |
The value can be specified using a human readable string with typical suffixes; |
| 2159 |
`B`, `MiB`, `GB`, etc. By default, if no suffix is provided, or the value is a |
| 2160 |
raw integer literal, the value is interpreted as if it were specified in bytes. |
| 2161 |
|
| 2162 |
Files that already exist in the working copy are not subject to this limit. |
| 2163 |
|
| 2164 |
Setting this value to zero will disable the limit entirely. |
| 2165 |
|
| 2166 |
### Automatic update of stale working copies |
| 2167 |
|
| 2168 |
When a working copy becomes stale (meaning the working copy's recorded commit is |
| 2169 |
no longer the current commit for that workspace), `jj` will normally prompt you |
| 2170 |
to update it with `jj workspace update-stale`. You can configure `jj` to |
| 2171 |
automatically update stale working copies by setting: |
| 2172 |
|
| 2173 |
```toml |
| 2174 |
[snapshot] |
| 2175 |
auto-update-stale = true |
| 2176 |
``` |
| 2177 |
|
| 2178 |
This is particularly useful if you have [multiple workspaces](working-copy.md#workspaces) |
| 2179 |
and want to avoid manually updating each one. |
| 2180 |
|
| 2181 |
For more information on stale working copies, see the [working copy |
| 2182 |
documentation](working-copy.md#stale-working-copy). |
| 2183 |
|
| 2184 |
## Working copy settings |
| 2185 |
|
| 2186 |
### EOL conversion setting |
| 2187 |
|
| 2188 |
This setting serves the same purpose as the [`core.autocrlf`][git-autocrlf] Git |
| 2189 |
config. |
| 2190 |
|
| 2191 |
Regardless of this setting, the line endings conversion is skipped on binary |
| 2192 |
files based on a [heuristic](#binary-file-detection). This is similar to Git. |
| 2193 |
|
| 2194 |
```toml |
| 2195 |
[working-copy] |
| 2196 |
# No EOL conversion. Similar to `core.autocrlf = false`. |
| 2197 |
eol-conversion = "none" |
| 2198 |
# Apply CRLF-to-LF EOL conversion when we check files in to the backend store |
| 2199 |
# from the local file system, but do not apply LF-to-CRLF EOL conversion when we |
| 2200 |
# check out the code from the backend store to the local file system. Similar to |
| 2201 |
# `core.autocrlf = input`. |
| 2202 |
eol-conversion = "input" |
| 2203 |
# Apply EOL conversion on both file check-in to and file check-out from the |
| 2204 |
# backend store, so you have CRLF line endings in your working directory while |
| 2205 |
# the repository has LF line endings. Similar to `core.autocrlf = true`. |
| 2206 |
eol-conversion = "input-output" |
| 2207 |
``` |
| 2208 |
|
| 2209 |
[git-autocrlf]: https://git-scm.com/book/en/v2/Customizing-Git-Git-Configuration#_core_autocrlf |
| 2210 |
|
| 2211 |
#### Binary file detection |
| 2212 |
|
| 2213 |
To detect if a file is binary, Jujutsu currently checks if there is a NULL byte |
| 2214 |
in the file, which is different from the algorithm of |
| 2215 |
[`gitoxide`][gitoxide-is-binary] or [`Git`][git-is-binary]. Jujutsu doesn't plan |
| 2216 |
to align the binary detection logic with Git. |
| 2217 |
|
| 2218 |
[gitoxide-is-binary]: https://github.com/GitoxideLabs/gitoxide/blob/073487b38ed40bcd7eb45dc110ae1ce84f9275a9/gix-filter/src/eol/utils.rs#L98-L100 |
| 2219 |
[git-is-binary]: https://github.com/git/git/blob/f1ca98f609f9a730b9accf24e5558a10a0b41b6c/convert.c#L94-L103 |
| 2220 |
|
| 2221 |
### Respect or ignore executable bit permission changes |
| 2222 |
|
| 2223 |
Whether to respect or ignore changes to the executable bit for files on Unix. |
| 2224 |
This option is unused on Windows. |
| 2225 |
|
| 2226 |
```toml |
| 2227 |
[working-copy] |
| 2228 |
exec-bit-change = "respect" | "ignore" | "auto" (default) |
| 2229 |
``` |
| 2230 |
|
| 2231 |
On Unix systems, files have a permission bit for whether they are executable as |
| 2232 |
scripts or binary code. Jujutsu stores this state in the repository and will |
| 2233 |
update it for files as you operate on a repository. If you set your working |
| 2234 |
copy to a commit where a file is recorded as executable or not, `jj` will |
| 2235 |
adjust the permission of that file. If you change a file's executable bit |
| 2236 |
through the filesystem, `jj` will record that change when taking a snapshot. |
| 2237 |
|
| 2238 |
Setting this to `"ignore"` will make Jujutsu ignore the executable bit on the |
| 2239 |
filesystem when updating the state for the repository. In addition, `jj` will |
| 2240 |
not attempt to modify a file's executable bit and will add new files as |
| 2241 |
"not executable." This is already the behavior on Windows, and having the |
| 2242 |
option to enable this behavior is useful for Unix users dual-booting Windows, |
| 2243 |
Windows users accessing files from WSL, or anyone experimenting with other |
| 2244 |
filesystem configurations. |
| 2245 |
|
| 2246 |
On Unix if `"auto"` is set (the default), `jj` will try to detect whether the |
| 2247 |
filesystem supports changing executable bits to choose between `"respect"` or |
| 2248 |
`"ignore"`. On errors, we assume `"respect"`, except if permission was denied |
| 2249 |
which will assume `"ignore"`. |
| 2250 |
|
| 2251 |
On Windows, files have no executable bit so this option is unused. |
| 2252 |
|
| 2253 |
You can always use `jj file chmod` to update the recorded executable bit for a |
| 2254 |
file manually. If this option is `"respect"`, `jj` will also attempt to |
| 2255 |
propagate that change to the filesystem. |
| 2256 |
|
| 2257 |
Note that if you modify a file's executable bit before changing this setting |
| 2258 |
from `"ignore"` or `"auto"` to `"respect"`, `jj` may not update the stored |
| 2259 |
executable bit until you modify the file's contents or update its modification |
| 2260 |
time, e.g. with `touch`. |
| 2261 |
|
| 2262 |
## Ways to specify `jj` config: details |
| 2263 |
|
| 2264 |
### User config files |
| 2265 |
|
| 2266 |
An easy way to find the user config file/directory is: |
| 2267 |
|
| 2268 |
```bash |
| 2269 |
jj config path --user |
| 2270 |
``` |
| 2271 |
|
| 2272 |
On all platforms, the user's global `jj` configurations are by default loaded in |
| 2273 |
the following precedence order (with later configs overriding earlier ones): |
| 2274 |
|
| 2275 |
- `$HOME/.jjconfig.toml` |
| 2276 |
- `<PLATFORM_SPECIFIC>/jj/config.toml` (preferred) |
| 2277 |
- `<PLATFORM_SPECIFIC>/jj/conf.d/*.toml` |
| 2278 |
|
| 2279 |
where `$HOME` represents the user's home directory (`%USERPROFILE%` on Windows), |
| 2280 |
and `<PLATFORM_SPECIFIC>` represents the platform-specific configuration |
| 2281 |
directory shown in the table below. The platform-specific location is |
| 2282 |
recommended for better integration with platform services. |
| 2283 |
|
| 2284 |
The files in the `conf.d` directory are loaded in lexicographic order. This |
| 2285 |
allows configs to be split across multiple files and combines well with |
| 2286 |
[Conditional Variables](#conditional-variables). Modifying user configuration |
| 2287 |
with `jj config {edit,set,unset} --user` targets the primary user config file |
| 2288 |
(or the first loaded file in `conf.d/`). Individual files in `conf.d/` can be |
| 2289 |
targeted with `--file <PATH>`. |
| 2290 |
|
| 2291 |
| Platform | Location of `<PLATFORM_SPECIFIC>` dir | Example config file location | |
| 2292 |
| :-------------- | :------------------------------------ | :-------------------------------------------------------- | |
| 2293 |
| Linux and macOS | `$XDG_CONFIG_HOME` or `$HOME/.config` | `/home/alice/.config/jj/config.toml` | |
| 2294 |
| Windows | `{FOLDERID_RoamingAppData}` | `C:\Users\Alice\AppData\Roaming\jj\config.toml` | |
| 2295 |
|
| 2296 |
The location of the `jj` user config files/directories can also be overridden |
| 2297 |
with the `JJ_CONFIG` environment variable. If the environment variable is set |
| 2298 |
(even to an empty string), it will be used instead of any configuration files in |
| 2299 |
the default locations. It can be a path to a TOML file or a directory of TOML |
| 2300 |
files, which will be loaded in lexicographic order and merged. Multiple paths |
| 2301 |
can be specified by separating them with a platform-specific path separator (`:` |
| 2302 |
on Unix-like systems, `;` on Windows). Note that this variable only affects |
| 2303 |
user-level and system-level config files; repo and workspace configs are |
| 2304 |
unaffected and will continue to be loaded from their respective locations. |
| 2305 |
(There is no environment variable to disable repo or workspace configs.) |
| 2306 |
|
| 2307 |
For example, the following could be used to run `jj` without loading any user or |
| 2308 |
system configs: |
| 2309 |
|
| 2310 |
```bash |
| 2311 |
# Ignores any settings specified in `{PLATFORM,/etc}/jj/{config.toml,conf.d/*.toml}`, |
| 2312 |
# but still loads repo and workspace configs. |
| 2313 |
JJ_CONFIG= jj log |
| 2314 |
``` |
| 2315 |
|
| 2316 |
There are also the `--config-file <PATH>` and `--config <NAME=VALUE>` |
| 2317 |
[global options](#specifying-config-on-the-command-line) which work with any |
| 2318 |
`jj` command. |
| 2319 |
|
| 2320 |
### System config files |
| 2321 |
|
| 2322 |
On Unix-like platforms, system-wide `jj` configurations are by default loaded in |
| 2323 |
the following precedence order (with later configs overriding earlier ones). |
| 2324 |
|
| 2325 |
- `/etc/jj/config.toml` |
| 2326 |
- `/etc/jj/conf.d/*.toml` |
| 2327 |
|
| 2328 |
These configs can be overridden by [the user config files], and will be disabled |
| 2329 |
in favor of the `JJ_CONFIG` environment variable if it is set. |
| 2330 |
|
| 2331 |
Existing system config files loaded by `jj` can be edited using |
| 2332 |
`jj config {edit,set,unset} --file <PATH>`. |
| 2333 |
|
| 2334 |
### JSON Schema Support |
| 2335 |
|
| 2336 |
Many popular editors support TOML file syntax highlighting and validation. To |
| 2337 |
enable schema validation in your editor, add this line at the top of your TOML |
| 2338 |
config files: |
| 2339 |
|
| 2340 |
```toml |
| 2341 |
#:schema https://docs.jj-vcs.dev/latest/config-schema.json |
| 2342 |
``` |
| 2343 |
|
| 2344 |
This enables features like: |
| 2345 |
|
| 2346 |
- Autocomplete for config keys |
| 2347 |
- Type checking of values |
| 2348 |
- Documentation on hover |
| 2349 |
- Validation of settings |
| 2350 |
|
| 2351 |
Here are some popular editors with TOML schema validation support: |
| 2352 |
|
| 2353 |
- VS Code |
| 2354 |
- Install [Even Better TOML](https://marketplace.visualstudio.com/items?itemName=tamasfe.even-better-toml) |
| 2355 |
|
| 2356 |
- Neovim/Vim |
| 2357 |
- Use with [nvim-lspconfig](https://github.com/neovim/nvim-lspconfig) and [taplo](https://github.com/tamasfe/taplo) |
| 2358 |
|
| 2359 |
- Helix |
| 2360 |
- Install [taplo](https://github.com/tamasfe/taplo) |
| 2361 |
|
| 2362 |
- JetBrains IDEs (IntelliJ, PyCharm, etc) |
| 2363 |
- Install [TOML](https://plugins.jetbrains.com/plugin/8195-toml) plugin |
| 2364 |
|
| 2365 |
- Emacs |
| 2366 |
- Install [lsp-mode](https://github.com/emacs-lsp/lsp-mode) and [toml-mode](https://github.com/dryman/toml-mode.el) |
| 2367 |
- Configure [taplo](https://github.com/tamasfe/taplo) as the LSP server |
| 2368 |
|
| 2369 |
### Specifying config on the command-line |
| 2370 |
|
| 2371 |
You can use one or more `--config`/`--config-file` options on the command line |
| 2372 |
to specify additional configuration settings. This overrides settings defined in |
| 2373 |
config files or environment variables. For example, |
| 2374 |
|
| 2375 |
```shell |
| 2376 |
# Must not have spaces around the `=` |
| 2377 |
jj --config ui.color=always --config ui.diff-editor=meld split |
| 2378 |
``` |
| 2379 |
|
| 2380 |
The config value should be specified as a TOML expression. If it is a string |
| 2381 |
value and isn't enclosed by any TOML constructs (such as array notation), quotes |
| 2382 |
can be omitted. Here is an example with more advanced TOML constructs: |
| 2383 |
|
| 2384 |
```shell |
| 2385 |
# Single quotes and the '\' are interpreted by the shell (assuming a POSIX shell) |
| 2386 |
# Double quotes are passed to jj and are parsed as TOML syntax |
| 2387 |
jj log --config \ |
| 2388 |
'template-aliases."format_timestamp(timestamp)"="""timestamp.format("%Y-%m-%d %H:%M %:::z")"""' |
| 2389 |
``` |
| 2390 |
|
| 2391 |
To load an entire TOML document, use `--config-file`: |
| 2392 |
|
| 2393 |
```shell |
| 2394 |
jj --config-file=extra-config.toml log |
| 2395 |
``` |
| 2396 |
|
| 2397 |
### Conditional variables |
| 2398 |
|
| 2399 |
You can conditionally enable config variables by using `--when`. |
| 2400 |
|
| 2401 |
#### Using `[[--scope]]` tables |
| 2402 |
|
| 2403 |
Variables defined in `[[--scope]]` tables are expanded to the root table. |
| 2404 |
`--when` specifies the condition to enable the scope table. |
| 2405 |
|
| 2406 |
If no conditions are specified, the table is always enabled. If multiple |
| 2407 |
conditions are specified, their intersection is used. |
| 2408 |
|
| 2409 |
```toml |
| 2410 |
[user] |
| 2411 |
name = "YOUR NAME" |
| 2412 |
email = "[email protected]" |
| 2413 |
|
| 2414 |
# override user.email if the repository is located under ~/oss |
| 2415 |
[[--scope]] |
| 2416 |
--when.repositories = ["~/oss"] |
| 2417 |
[--scope.user] |
| 2418 |
email = "[email protected]" |
| 2419 |
|
| 2420 |
# override ui.pager on specific machines |
| 2421 |
[[--scope]] |
| 2422 |
--when.hostnames = ["work-laptop", "work-desktop"] |
| 2423 |
[--scope.ui] |
| 2424 |
pager = "delta" |
| 2425 |
|
| 2426 |
# disable pagination for `jj status`, use `delta` for `jj diff` and `jj show` |
| 2427 |
[[--scope]] |
| 2428 |
--when.commands = ["status"] |
| 2429 |
[--scope.ui] |
| 2430 |
paginate = "never" |
| 2431 |
[[--scope]] |
| 2432 |
--when.commands = ["diff", "show"] |
| 2433 |
[--scope.ui] |
| 2434 |
pager = "delta" |
| 2435 |
``` |
| 2436 |
|
| 2437 |
#### Using multiple files |
| 2438 |
|
| 2439 |
`--when` can also be used on the top level of a TOML file, which is convenient |
| 2440 |
when splitting your config across multiple files. |
| 2441 |
The behavior of conditions are the same as when using `[[--scope]]` tables. |
| 2442 |
|
| 2443 |
```toml |
| 2444 |
# In $XDG_CONFIG_HOME/jj/config.toml |
| 2445 |
[user] |
| 2446 |
name = "YOUR NAME" |
| 2447 |
email = "[email protected]" |
| 2448 |
``` |
| 2449 |
|
| 2450 |
```toml |
| 2451 |
# In $XDG_CONFIG_HOME/jj/conf.d/work.toml |
| 2452 |
--when.repositories = ["~/the/work/repo"] |
| 2453 |
|
| 2454 |
[user] |
| 2455 |
email = "[email protected]" |
| 2456 |
|
| 2457 |
[revset-aliases] |
| 2458 |
work = "heads(::@ ~ description(''))::" |
| 2459 |
|
| 2460 |
[aliases] |
| 2461 |
wip = ["log", "-r", "work"] |
| 2462 |
``` |
| 2463 |
|
| 2464 |
You can modify specific configuration files such as those in |
| 2465 |
`conf.d/` directly using the `--file` option (the file will be created if it |
| 2466 |
doesn't already exist): |
| 2467 |
|
| 2468 |
```shell |
| 2469 |
jj config set --file ~/.config/jj/conf.d/work.toml user.email "[email protected]" |
| 2470 |
jj config edit --file ~/.config/jj/conf.d/work.toml |
| 2471 |
``` |
| 2472 |
|
| 2473 |
#### Available condition keys |
| 2474 |
|
| 2475 |
* `--when.repositories`: List of paths to match the repository path prefix. |
| 2476 |
|
| 2477 |
Paths should be absolute. Each path component (directory or file name, drive |
| 2478 |
letter, etc.) is compared case-sensitively on all platforms. A path starting |
| 2479 |
with `~` is expanded to the home directory. On Windows, directory separator may |
| 2480 |
be either `\` or `/`. (Beware that `\` needs escape in double-quoted strings.) |
| 2481 |
|
| 2482 |
Use `jj root` to see the workspace root directory. Note that the repository path |
| 2483 |
is in the main workspace if you're using multiple workspaces with `jj |
| 2484 |
workspace`. |
| 2485 |
|
| 2486 |
* `--when.workspaces`: List of paths to match the workspace path prefix. |
| 2487 |
|
| 2488 |
The same concerns about the path as for `--when.repositories` applies. |
| 2489 |
|
| 2490 |
Use `jj root` to see the workspace root directory. |
| 2491 |
|
| 2492 |
* `--when.hostnames`: List of hostnames to match against the `operation.hostname` |
| 2493 |
config setting. |
| 2494 |
|
| 2495 |
Hostnames are compared case-sensitively and must match exactly. |
| 2496 |
|
| 2497 |
```toml |
| 2498 |
--when.hostnames = ["work-laptop"] # matches only "work-laptop" |
| 2499 |
--when.hostnames = ["home-desktop", "laptop"] # matches "home-desktop" *OR* "laptop" |
| 2500 |
``` |
| 2501 |
|
| 2502 |
* `--when.commands`: List of subcommands to match. |
| 2503 |
|
| 2504 |
Subcommands are space-separated and matched by prefix. |
| 2505 |
|
| 2506 |
```toml |
| 2507 |
--when.commands = ["file"] # matches `jj file show`, `jj file list`, etc |
| 2508 |
--when.commands = ["file show"] # matches `jj file show` but *NOT* `jj file list` |
| 2509 |
--when.commands = ["file", "log"] # matches `jj file` *OR* `jj log` (*OR* subcommand of either) |
| 2510 |
``` |
| 2511 |
|
| 2512 |
* `--when.platforms`: List of platforms to match. |
| 2513 |
|
| 2514 |
The values are defined by both |
| 2515 |
[`std::env::consts::FAMILY`](https://doc.rust-lang.org/std/env/consts/constant.FAMILY.html) |
| 2516 |
and |
| 2517 |
[`std::env::consts::OS`](https://doc.rust-lang.org/std/env/consts/constant.OS.html). |
| 2518 |
|
| 2519 |
```toml |
| 2520 |
--when.platforms = ["windows"] # matches only Windows |
| 2521 |
--when.platforms = ["linux", "freebsd"] # matches Linux *OR* FreeBSD, but *NOT* macOS |
| 2522 |
--when.platforms = ["unix"] # matches anything in the Unix family (Linux, FreeBSD, macOS, etc.) |
| 2523 |
``` |
| 2524 |
|
| 2525 |
* `--when.environments`: List of environment variable conditions in |
| 2526 |
`"NAME=VALUE"` format (check if the variable has the value), or `NAME` to |
| 2527 |
check if the variable is set. |
| 2528 |
|
| 2529 |
```toml |
| 2530 |
--when.environments = ["CI=true"] # matches when CI is set to "true" |
| 2531 |
--when.environments = ["CI"] # matches when CI is set to anything |
| 2532 |
--when.environments = ["CI=true", "CI=1"] # matches when CI is "true" *OR* "1" |
| 2533 |
--when.environments = ["CI=true", "GITHUB_ACTIONS=1"] # matches when *EITHER* condition holds |
| 2534 |
``` |