2022-07-03 05:16:01 +00:00
|
|
|
# Configuration
|
|
|
|
|
|
|
|
These are the config settings available to jj/Jujutsu.
|
|
|
|
|
2023-02-16 19:42:31 +00:00
|
|
|
|
2023-02-16 19:42:31 +00:00
|
|
|
## Config files and TOML
|
2023-02-16 19:42:31 +00:00
|
|
|
|
2024-02-01 04:53:23 +00:00
|
|
|
`jj` loads several types of config settings:
|
2022-07-03 05:16:01 +00:00
|
|
|
|
2024-02-01 04:53:23 +00:00
|
|
|
- The built-in settings. These cannot be edited. They can be viewed in the
|
|
|
|
`cli/src/config/` directory in `jj`'s source repo.
|
2023-01-02 05:18:38 +00:00
|
|
|
|
2024-02-01 04:53:23 +00:00
|
|
|
- The user settings. These can be edited with `jj config edit --user`. User
|
|
|
|
settings are located in [the user config file], which can be found with `jj
|
|
|
|
config path --user`.
|
2023-02-16 19:42:31 +00:00
|
|
|
|
2024-02-01 04:53:23 +00:00
|
|
|
- The repo settings. These can be edited with `jj config edit --repo` and are
|
|
|
|
located in `.jj/repo/config.toml`.
|
|
|
|
|
|
|
|
- Settings [specified in the command-line](#specifying-config-on-the-command-line).
|
|
|
|
|
|
|
|
These are listed in the order they are loaded; the settings from earlier items
|
|
|
|
in
|
|
|
|
the list are overridden by the settings from later items if they disagree. Every
|
|
|
|
type of config except for the built-in settings is optional.
|
|
|
|
|
|
|
|
See the [TOML site] and the [syntax guide] for a detailed description of the
|
|
|
|
syntax. We cover some of the basics below.
|
|
|
|
|
|
|
|
[the user config file]: #user-config-file
|
2023-02-16 19:42:31 +00:00
|
|
|
[TOML site]: https://toml.io/en/
|
|
|
|
[syntax guide]: https://toml.io/en/v1.0.0
|
|
|
|
|
|
|
|
The first thing to remember is that the value of a setting (the part to the
|
|
|
|
right of the `=` sign) should be surrounded in quotes if it's a string.
|
|
|
|
|
|
|
|
### Dotted style and headings
|
|
|
|
In TOML, anything under a heading can be dotted instead. For example,
|
|
|
|
`user.name = "YOUR NAME"` is equivalent to:
|
2022-07-03 05:16:01 +00:00
|
|
|
|
2023-01-27 01:18:08 +00:00
|
|
|
```toml
|
|
|
|
[user]
|
|
|
|
name = "YOUR NAME"
|
|
|
|
```
|
2022-07-03 05:16:01 +00:00
|
|
|
|
2023-02-16 19:42:31 +00:00
|
|
|
For future reference, here are a couple of more complicated examples,
|
2023-02-16 06:06:52 +00:00
|
|
|
|
|
|
|
```toml
|
2023-02-16 19:42:31 +00:00
|
|
|
# Dotted style
|
|
|
|
template-aliases."format_short_id(id)" = "id.shortest(12)"
|
|
|
|
colors."commit_id prefix".bold = true
|
|
|
|
|
|
|
|
# is equivalent to:
|
2023-02-16 06:06:52 +00:00
|
|
|
[template-aliases]
|
|
|
|
"format_short_id(id)" = "id.shortest(12)"
|
|
|
|
|
2023-02-16 19:42:31 +00:00
|
|
|
[colors]
|
|
|
|
"commit_id prefix" = { bold = true }
|
|
|
|
```
|
2023-02-16 06:06:52 +00:00
|
|
|
|
|
|
|
Jujutsu favors the dotted style in these instructions, if only because it's
|
|
|
|
easier to write down in an unconfusing way. If you are confident with TOML
|
|
|
|
then use whichever suits you in your config. If you mix dotted keys and headings,
|
|
|
|
**put the dotted keys before the first heading**.
|
2022-07-03 05:16:01 +00:00
|
|
|
|
2023-02-16 19:42:31 +00:00
|
|
|
That's probably enough TOML to keep you out of trouble but the [syntax guide] is
|
|
|
|
very short if you ever need to check.
|
2022-07-03 05:16:01 +00:00
|
|
|
|
2023-02-16 06:12:22 +00:00
|
|
|
|
2022-07-03 05:16:01 +00:00
|
|
|
## User settings
|
|
|
|
|
2023-01-27 01:18:08 +00:00
|
|
|
```toml
|
|
|
|
user.name = "YOUR NAME"
|
|
|
|
user.email = "YOUR_EMAIL@example.com"
|
|
|
|
```
|
2022-07-03 05:16:01 +00:00
|
|
|
|
|
|
|
Don't forget to change these to your own details!
|
|
|
|
|
|
|
|
## UI settings
|
|
|
|
|
|
|
|
### Colorizing output
|
|
|
|
|
2024-05-06 16:23:36 +00:00
|
|
|
Possible values are `always`, `never`, `debug` and `auto` (default: `auto`).
|
|
|
|
`auto` will use color only when writing to a terminal. `debug` will print the
|
|
|
|
active labels alongside the regular colorized output.
|
2022-07-03 05:16:01 +00:00
|
|
|
|
|
|
|
This setting overrides the `NO_COLOR` environment variable (if set).
|
|
|
|
|
2023-01-27 01:18:08 +00:00
|
|
|
```toml
|
|
|
|
ui.color = "never" # Turn off color
|
|
|
|
```
|
2022-07-03 05:16:01 +00:00
|
|
|
|
2023-01-27 17:16:06 +00:00
|
|
|
### Custom colors and styles
|
|
|
|
|
|
|
|
You can customize the colors used for various elements of the UI. For example:
|
|
|
|
|
|
|
|
```toml
|
|
|
|
colors.commit_id = "green"
|
|
|
|
```
|
|
|
|
|
|
|
|
The following colors are available:
|
|
|
|
|
|
|
|
* black
|
|
|
|
* red
|
|
|
|
* green
|
|
|
|
* yellow
|
|
|
|
* blue
|
|
|
|
* magenta
|
|
|
|
* cyan
|
|
|
|
* white
|
2023-04-08 06:25:30 +00:00
|
|
|
* default
|
2023-01-27 17:16:06 +00:00
|
|
|
|
2023-04-08 06:25:30 +00:00
|
|
|
All of them but "default" come in a bright version too, e.g. "bright red". The
|
|
|
|
"default" color can be used to override a color defined by a parent style
|
|
|
|
(explained below).
|
2023-01-27 17:16:06 +00:00
|
|
|
|
2024-03-16 08:45:40 +00:00
|
|
|
You can also use a 6-digit hex code for more control over the exact color used:
|
|
|
|
|
|
|
|
```toml
|
|
|
|
colors.change_id = "#ff1525"
|
|
|
|
```
|
|
|
|
|
|
|
|
If you use a string value for a color, as in the examples above, it will be used
|
2023-01-27 17:16:06 +00:00
|
|
|
for the foreground color. You can also set the background color, or make the
|
|
|
|
text bold or underlined. For that, you need to use a table:
|
|
|
|
|
|
|
|
```toml
|
2024-03-16 08:45:40 +00:00
|
|
|
colors.commit_id = { fg = "green", bg = "#ff1525", bold = true, underline = true }
|
2023-01-27 17:16:06 +00:00
|
|
|
```
|
|
|
|
|
|
|
|
The key names are called "labels". The above used `commit_id` as label. You can
|
|
|
|
also create rules combining multiple labels. The rules work a bit like CSS
|
|
|
|
selectors. For example, if you want to color commit IDs green in general but
|
|
|
|
make the commit ID of the working-copy commit also be underlined, you can do
|
|
|
|
this:
|
|
|
|
|
|
|
|
```toml
|
|
|
|
colors.commit_id = "green"
|
2023-01-31 06:51:14 +00:00
|
|
|
colors."working_copy commit_id" = { underline = true }
|
2023-01-27 17:16:06 +00:00
|
|
|
```
|
|
|
|
|
|
|
|
Parts of the style that are not overridden - such as the foreground color in the
|
|
|
|
example above - are inherited from the parent style.
|
|
|
|
|
|
|
|
Which elements can be colored is not yet documented, but see
|
2023-08-17 09:24:07 +00:00
|
|
|
the [default color configuration](https://github.com/martinvonz/jj/blob/main/cli/src/config/colors.toml)
|
2023-01-27 17:16:06 +00:00
|
|
|
for some examples of what's possible.
|
|
|
|
|
2023-04-14 01:49:35 +00:00
|
|
|
### Default command
|
|
|
|
|
|
|
|
When `jj` is run with no explicit subcommand, the value of the
|
2023-04-18 08:03:32 +00:00
|
|
|
`ui.default-command` setting will be used instead. Possible values are any valid
|
2023-04-14 01:49:35 +00:00
|
|
|
subcommand name, subcommand alias, or user-defined alias (defaults to `"log"`).
|
|
|
|
|
|
|
|
```toml
|
2024-04-04 17:30:37 +00:00
|
|
|
ui.default-command = ["log", "--reversed"]
|
2023-04-14 01:49:35 +00:00
|
|
|
```
|
|
|
|
|
2023-08-12 10:19:27 +00:00
|
|
|
### Default description
|
|
|
|
|
2024-07-20 08:46:50 +00:00
|
|
|
The editor content of a commit description can be populated by the
|
|
|
|
`draft_commit_description` template.
|
|
|
|
|
|
|
|
```toml
|
|
|
|
[templates]
|
|
|
|
draft_commit_description = '''
|
|
|
|
concat(
|
|
|
|
description,
|
|
|
|
surround(
|
|
|
|
"\nJJ: This commit contains the following changes:\n", "",
|
|
|
|
indent("JJ: ", diff.stat(72)),
|
|
|
|
),
|
|
|
|
)
|
|
|
|
'''
|
|
|
|
```
|
|
|
|
|
|
|
|
The value of the `ui.default-description` setting can also be used in order to
|
|
|
|
fill in things like BUG=, TESTED= etc.
|
2023-08-12 10:19:27 +00:00
|
|
|
|
|
|
|
```toml
|
|
|
|
ui.default-description = "\n\nTESTED=TODO"
|
|
|
|
```
|
|
|
|
|
2024-06-30 06:41:44 +00:00
|
|
|
### Diff colors and styles
|
|
|
|
|
2024-06-28 03:11:04 +00:00
|
|
|
In color-words and git diffs, word-level hunks are rendered with underline. You
|
|
|
|
can override the default style with the following keys:
|
2024-06-30 06:41:44 +00:00
|
|
|
|
|
|
|
```toml
|
|
|
|
[colors]
|
|
|
|
# Highlight hunks with background
|
|
|
|
"diff removed token" = { bg = "#221111", underline = false }
|
|
|
|
"diff added token" = { bg = "#002200", underline = false }
|
|
|
|
```
|
|
|
|
|
2023-02-06 06:30:29 +00:00
|
|
|
### Diff format
|
|
|
|
|
|
|
|
```toml
|
|
|
|
# Possible values: "color-words" (default), "git", "summary"
|
|
|
|
ui.diff.format = "git"
|
|
|
|
```
|
diff: add option to display complex color-words diffs without inlining
In this patch, I use the number of adds<->removes alternation as a threshold,
which approximates the visual complexity of diff hunks. I don't think user can
choose the threshold intuitively, but we need a config knob to try out some.
I set `max-inline-alternation = 3` locally. 0 and 1 mean "disable inlining"
and "inline adds-only/removes-only lines" respectively.
I've added "diff.<format>" config namespace assuming "ui.diff" will be
reorganized as "ui.diff-formatter" or something. #3327
Some other metrics I've tried:
```
// Per-line alternation. This also works well, but can't measure complexity of
// changes across lines.
fn count_max_diff_alternation_per_line(diff_lines: &[DiffLine]) -> usize {
diff_lines
.iter()
.map(|line| {
let sides = line.hunks.iter().map(|&(side, _)| side);
sides
.filter(|&side| side != DiffLineHunkSide::Both)
.dedup() // omit e.g. left->both->left
.count()
})
.max()
.unwrap_or(0)
}
// Per-line occupancy of changes. Large diffs don't always look complex.
fn max_diff_token_ratio_per_line(diff_lines: &[DiffLine]) -> f32 {
diff_lines
.iter()
.filter_map(|line| {
let [both_len, left_len, right_len] =
line.hunks.iter().fold([0, 0, 0], |mut acc, (side, data)| {
let index = match side {
DiffLineHunkSide::Both => 0,
DiffLineHunkSide::Left => 1,
DiffLineHunkSide::Right => 2,
};
acc[index] += data.len();
acc
});
// left/right-only change is readable
(left_len != 0 && right_len != 0).then(|| {
let diff_len = left_len + right_len;
let total_len = both_len + left_len + right_len;
(diff_len as f32) / (total_len as f32)
})
})
.reduce(f32::max)
.unwrap_or(0.0)
}
// Total occupancy of changes. Large diffs don't always look complex.
fn total_change_ratio(diff_lines: &[DiffLine]) -> f32 {
let (diff_len, total_len) = diff_lines
.iter()
.flat_map(|line| &line.hunks)
.fold((0, 0), |(diff_len, total_len), (side, data)| {
let l = data.len();
match side {
DiffLineHunkSide::Both => (diff_len, total_len + l),
DiffLineHunkSide::Left => (diff_len + l, total_len + l),
DiffLineHunkSide::Right => (diff_len + l, total_len + l),
}
});
(diff_len as f32) / (total_len as f32)
}
```
2024-08-14 08:47:11 +00:00
|
|
|
|
|
|
|
#### Color-words diff options
|
|
|
|
|
|
|
|
In color-words diffs, changed words are displayed inline by default. Because
|
|
|
|
it's difficult to read a diff line with many removed/added words, there's a
|
|
|
|
threshold to switch to traditional separate-line format.
|
|
|
|
|
|
|
|
* `max-inline-alternation`: Maximum number of removed/added word alternation to
|
|
|
|
inline. For example, `<added> ... <added>` sequence has 1 alternation, so the
|
|
|
|
line will be inline if `max-inline-alternation >= 1`. `<added> ... <removed>
|
|
|
|
... <added>` sequence has 3 alternation.
|
|
|
|
|
|
|
|
* `0`: disable inlining, making `--color-words` more similar to `--git`
|
|
|
|
* `1`: inline removes-only or adds-only lines
|
|
|
|
* `2`, `3`, ..: inline up to `2`, `3`, .. alternation
|
2024-08-27 11:34:48 +00:00
|
|
|
* `-1`: inline all lines
|
|
|
|
|
|
|
|
The default is `3`.
|
diff: add option to display complex color-words diffs without inlining
In this patch, I use the number of adds<->removes alternation as a threshold,
which approximates the visual complexity of diff hunks. I don't think user can
choose the threshold intuitively, but we need a config knob to try out some.
I set `max-inline-alternation = 3` locally. 0 and 1 mean "disable inlining"
and "inline adds-only/removes-only lines" respectively.
I've added "diff.<format>" config namespace assuming "ui.diff" will be
reorganized as "ui.diff-formatter" or something. #3327
Some other metrics I've tried:
```
// Per-line alternation. This also works well, but can't measure complexity of
// changes across lines.
fn count_max_diff_alternation_per_line(diff_lines: &[DiffLine]) -> usize {
diff_lines
.iter()
.map(|line| {
let sides = line.hunks.iter().map(|&(side, _)| side);
sides
.filter(|&side| side != DiffLineHunkSide::Both)
.dedup() // omit e.g. left->both->left
.count()
})
.max()
.unwrap_or(0)
}
// Per-line occupancy of changes. Large diffs don't always look complex.
fn max_diff_token_ratio_per_line(diff_lines: &[DiffLine]) -> f32 {
diff_lines
.iter()
.filter_map(|line| {
let [both_len, left_len, right_len] =
line.hunks.iter().fold([0, 0, 0], |mut acc, (side, data)| {
let index = match side {
DiffLineHunkSide::Both => 0,
DiffLineHunkSide::Left => 1,
DiffLineHunkSide::Right => 2,
};
acc[index] += data.len();
acc
});
// left/right-only change is readable
(left_len != 0 && right_len != 0).then(|| {
let diff_len = left_len + right_len;
let total_len = both_len + left_len + right_len;
(diff_len as f32) / (total_len as f32)
})
})
.reduce(f32::max)
.unwrap_or(0.0)
}
// Total occupancy of changes. Large diffs don't always look complex.
fn total_change_ratio(diff_lines: &[DiffLine]) -> f32 {
let (diff_len, total_len) = diff_lines
.iter()
.flat_map(|line| &line.hunks)
.fold((0, 0), |(diff_len, total_len), (side, data)| {
let l = data.len();
match side {
DiffLineHunkSide::Both => (diff_len, total_len + l),
DiffLineHunkSide::Left => (diff_len + l, total_len + l),
DiffLineHunkSide::Right => (diff_len + l, total_len + l),
}
});
(diff_len as f32) / (total_len as f32)
}
```
2024-08-14 08:47:11 +00:00
|
|
|
|
|
|
|
**This parameter is experimental.** The definition is subject to change.
|
|
|
|
|
|
|
|
```toml
|
|
|
|
[diff.color-words]
|
|
|
|
max-inline-alternation = 3
|
|
|
|
```
|
2023-02-06 06:30:29 +00:00
|
|
|
|
2023-08-02 03:12:11 +00:00
|
|
|
### Generating diffs by external command
|
|
|
|
|
2023-08-03 22:25:22 +00:00
|
|
|
If `ui.diff.tool` is set, the specified diff command will be called instead of
|
|
|
|
the internal diff function.
|
|
|
|
|
|
|
|
```toml
|
2024-03-01 18:54:31 +00:00
|
|
|
[ui]
|
2023-08-03 22:25:22 +00:00
|
|
|
# Use Difftastic by default
|
2024-03-01 18:54:31 +00:00
|
|
|
diff.tool = ["difft", "--color=always", "$left", "$right"]
|
2023-08-03 22:25:22 +00:00
|
|
|
# Use tool named "<name>" (see below)
|
2024-03-01 18:54:31 +00:00
|
|
|
diff.tool = "<name>"
|
2023-08-03 22:25:22 +00:00
|
|
|
```
|
|
|
|
|
|
|
|
The external diff tool can also be enabled by `diff --tool <name>` argument.
|
|
|
|
For the tool named `<name>`, command arguments can be configured as follows.
|
2023-08-02 03:12:11 +00:00
|
|
|
|
|
|
|
```toml
|
|
|
|
[merge-tools.<name>]
|
|
|
|
# program = "<name>" # Defaults to the name of the tool if not specified
|
|
|
|
diff-args = ["--color=always", "$left", "$right"]
|
|
|
|
```
|
|
|
|
|
|
|
|
- `$left` and `$right` are replaced with the paths to the left and right
|
|
|
|
directories to diff respectively.
|
|
|
|
|
2024-06-27 15:53:14 +00:00
|
|
|
By default `jj` will invoke external tools with a directory containing the left
|
|
|
|
and right sides. The `diff-invocation-mode` config can change this to file by file
|
|
|
|
invocations as follows:
|
|
|
|
|
|
|
|
```toml
|
|
|
|
[ui]
|
|
|
|
diff.tool = "vimdiff"
|
|
|
|
|
|
|
|
[merge-tools.vimdiff]
|
|
|
|
diff-invocation-mode = "file-by-file"
|
|
|
|
```
|
|
|
|
|
cli: make set of immutable commits configurable
This adds a new `revset-aliases.immutable_heads()s` config for
defining the set of immutable commits. The set is defined as the
configured revset, as well as its ancestors, and the root commit
commit (even if the configured set is empty).
This patch also adds enforcement of the config where we already had
checks preventing rewrite of the root commit. The working-copy commit
is implicitly assumed to be writable in most cases. Specifically, we
won't prevent amending the working copy even if the user includes it
in the config but we do prevent `jj edit @` in that case. That seems
good enough to me. Maybe we should emit a warning when the working
copy is in the set of immutable commits.
Maybe we should add support for something more like [Mercurial's
phases](https://wiki.mercurial-scm.org/Phases), which is propagated on
push and pull. There's already some affordance for that in the view
object's `public_heads` field. However, this is simpler, especially
since we can't propagate the phase to Git remotes, and seems like a
good start. Also, it lets you say that commits authored by other users
are immutable, for example.
For now, the functionality is in the CLI library. I'm not sure if we
want to move it into the library crate. I'm leaning towards letting
library users do whatever they want without being restricted by
immutable commits. I do think we should move the functionality into a
future `ui-lib` or `ui-util` crate. That crate would have most of the
functionality in the current `cli_util` module (but in a
non-CLI-specific form).
2023-09-02 02:12:01 +00:00
|
|
|
### Set of immutable commits
|
|
|
|
|
2024-07-14 01:59:19 +00:00
|
|
|
You can configure the set of immutable commits via
|
|
|
|
`revset-aliases."immutable_heads()"`. The default set of immutable heads is
|
2024-08-21 19:59:15 +00:00
|
|
|
`trunk() | tags() | untracked_remote_bookmarks()`. For example, to prevent
|
2024-07-14 01:59:19 +00:00
|
|
|
rewriting commits on `main@origin` and commits authored by other users:
|
cli: make set of immutable commits configurable
This adds a new `revset-aliases.immutable_heads()s` config for
defining the set of immutable commits. The set is defined as the
configured revset, as well as its ancestors, and the root commit
commit (even if the configured set is empty).
This patch also adds enforcement of the config where we already had
checks preventing rewrite of the root commit. The working-copy commit
is implicitly assumed to be writable in most cases. Specifically, we
won't prevent amending the working copy even if the user includes it
in the config but we do prevent `jj edit @` in that case. That seems
good enough to me. Maybe we should emit a warning when the working
copy is in the set of immutable commits.
Maybe we should add support for something more like [Mercurial's
phases](https://wiki.mercurial-scm.org/Phases), which is propagated on
push and pull. There's already some affordance for that in the view
object's `public_heads` field. However, this is simpler, especially
since we can't propagate the phase to Git remotes, and seems like a
good start. Also, it lets you say that commits authored by other users
are immutable, for example.
For now, the functionality is in the CLI library. I'm not sure if we
want to move it into the library crate. I'm leaning towards letting
library users do whatever they want without being restricted by
immutable commits. I do think we should move the functionality into a
future `ui-lib` or `ui-util` crate. That crate would have most of the
functionality in the current `cli_util` module (but in a
non-CLI-specific form).
2023-09-02 02:12:01 +00:00
|
|
|
|
|
|
|
```toml
|
|
|
|
# The `main.. &` bit is an optimization to scan for non-`mine()` commits only
|
|
|
|
# among commits that are not in `main`.
|
|
|
|
revset-aliases."immutable_heads()" = "main@origin | (main@origin.. & ~mine())"
|
|
|
|
```
|
|
|
|
|
2023-09-27 17:05:41 +00:00
|
|
|
Ancestors of the configured set are also immutable. The root commit is always
|
cli: make set of immutable commits configurable
This adds a new `revset-aliases.immutable_heads()s` config for
defining the set of immutable commits. The set is defined as the
configured revset, as well as its ancestors, and the root commit
commit (even if the configured set is empty).
This patch also adds enforcement of the config where we already had
checks preventing rewrite of the root commit. The working-copy commit
is implicitly assumed to be writable in most cases. Specifically, we
won't prevent amending the working copy even if the user includes it
in the config but we do prevent `jj edit @` in that case. That seems
good enough to me. Maybe we should emit a warning when the working
copy is in the set of immutable commits.
Maybe we should add support for something more like [Mercurial's
phases](https://wiki.mercurial-scm.org/Phases), which is propagated on
push and pull. There's already some affordance for that in the view
object's `public_heads` field. However, this is simpler, especially
since we can't propagate the phase to Git remotes, and seems like a
good start. Also, it lets you say that commits authored by other users
are immutable, for example.
For now, the functionality is in the CLI library. I'm not sure if we
want to move it into the library crate. I'm leaning towards letting
library users do whatever they want without being restricted by
immutable commits. I do think we should move the functionality into a
future `ui-lib` or `ui-util` crate. That crate would have most of the
functionality in the current `cli_util` module (but in a
non-CLI-specific form).
2023-09-02 02:12:01 +00:00
|
|
|
immutable even if the set is empty.
|
|
|
|
|
2024-05-14 20:43:30 +00:00
|
|
|
## Log
|
|
|
|
|
|
|
|
### Default revisions
|
2023-05-11 06:26:23 +00:00
|
|
|
|
2024-03-31 09:47:31 +00:00
|
|
|
You can configure the revisions `jj log` would show when neither `-r` nor any paths are specified.
|
2023-05-11 06:26:23 +00:00
|
|
|
|
|
|
|
```toml
|
cli: make set of immutable commits configurable
This adds a new `revset-aliases.immutable_heads()s` config for
defining the set of immutable commits. The set is defined as the
configured revset, as well as its ancestors, and the root commit
commit (even if the configured set is empty).
This patch also adds enforcement of the config where we already had
checks preventing rewrite of the root commit. The working-copy commit
is implicitly assumed to be writable in most cases. Specifically, we
won't prevent amending the working copy even if the user includes it
in the config but we do prevent `jj edit @` in that case. That seems
good enough to me. Maybe we should emit a warning when the working
copy is in the set of immutable commits.
Maybe we should add support for something more like [Mercurial's
phases](https://wiki.mercurial-scm.org/Phases), which is propagated on
push and pull. There's already some affordance for that in the view
object's `public_heads` field. However, this is simpler, especially
since we can't propagate the phase to Git remotes, and seems like a
good start. Also, it lets you say that commits authored by other users
are immutable, for example.
For now, the functionality is in the CLI library. I'm not sure if we
want to move it into the library crate. I'm leaning towards letting
library users do whatever they want without being restricted by
immutable commits. I do think we should move the functionality into a
future `ui-lib` or `ui-util` crate. That crate would have most of the
functionality in the current `cli_util` module (but in a
non-CLI-specific form).
2023-09-02 02:12:01 +00:00
|
|
|
# Show commits that are not in `main@origin`
|
|
|
|
revsets.log = "main@origin.."
|
2023-05-11 06:26:23 +00:00
|
|
|
```
|
|
|
|
|
2024-05-03 21:09:24 +00:00
|
|
|
The default value for `revsets.log` is `'@ | ancestors(immutable_heads().., 2) | trunk()'`.
|
|
|
|
|
2023-01-27 06:33:24 +00:00
|
|
|
### Graph style
|
|
|
|
|
|
|
|
```toml
|
2024-02-11 18:43:06 +00:00
|
|
|
# Possible values: "curved" (default), "square", "ascii", "ascii-large"
|
2023-02-09 02:53:47 +00:00
|
|
|
ui.graph.style = "square"
|
2023-01-27 06:33:24 +00:00
|
|
|
```
|
|
|
|
|
2024-03-11 22:16:24 +00:00
|
|
|
#### Node style
|
|
|
|
|
|
|
|
The symbols used to represent commits or operations can be customized via
|
|
|
|
templates.
|
|
|
|
|
2024-09-04 03:13:48 +00:00
|
|
|
- `templates.log_node` for commits (with `Option<Commit>` keywords)
|
|
|
|
- `templates.op_log_node` for operations (with `Operation` keywords)
|
2024-03-11 22:16:24 +00:00
|
|
|
|
|
|
|
For example:
|
|
|
|
```toml
|
|
|
|
[templates]
|
|
|
|
log_node = '''
|
2024-03-25 09:19:36 +00:00
|
|
|
coalesce(
|
|
|
|
if(!self, "🮀"),
|
|
|
|
if(current_working_copy, "@"),
|
|
|
|
if(root, "┴"),
|
|
|
|
if(immutable, "●", "○"),
|
2024-03-18 12:52:25 +00:00
|
|
|
)
|
2024-03-11 22:16:24 +00:00
|
|
|
'''
|
|
|
|
op_log_node = 'if(current_operation, "@", "○")'
|
|
|
|
```
|
|
|
|
|
2023-03-05 04:10:02 +00:00
|
|
|
### Wrap log content
|
|
|
|
|
2024-07-24 13:49:18 +00:00
|
|
|
If enabled, `log`/`evolog`/`op log` content will be wrapped based on
|
2023-03-05 04:10:02 +00:00
|
|
|
the terminal width.
|
|
|
|
|
|
|
|
```toml
|
|
|
|
ui.log-word-wrap = true
|
|
|
|
```
|
|
|
|
|
2023-02-06 00:10:25 +00:00
|
|
|
### Display of commit and change ids
|
|
|
|
|
2023-02-15 10:15:05 +00:00
|
|
|
Can be customized by the `format_short_id()` template alias.
|
2023-01-07 03:00:37 +00:00
|
|
|
|
2023-02-06 00:10:25 +00:00
|
|
|
```toml
|
2023-02-15 10:15:05 +00:00
|
|
|
[template-aliases]
|
|
|
|
# Highlight unique prefix and show at least 12 characters (default)
|
|
|
|
'format_short_id(id)' = 'id.shortest(12)'
|
|
|
|
# Just the shortest possible unique prefix
|
|
|
|
'format_short_id(id)' = 'id.shortest()'
|
|
|
|
# Show unique prefix and the rest surrounded by brackets
|
2023-02-28 11:30:57 +00:00
|
|
|
'format_short_id(id)' = 'id.shortest(12).prefix() ++ "[" ++ id.shortest(12).rest() ++ "]"'
|
2023-02-15 10:15:05 +00:00
|
|
|
# Always show 12 characters
|
|
|
|
'format_short_id(id)' = 'id.short(12)'
|
2023-02-06 00:10:25 +00:00
|
|
|
```
|
|
|
|
|
2023-02-21 04:38:52 +00:00
|
|
|
To customize these separately, use the `format_short_commit_id()` and
|
|
|
|
`format_short_change_id()` aliases:
|
|
|
|
|
|
|
|
```toml
|
|
|
|
[template-aliases]
|
|
|
|
# Uppercase change ids. `jj` treats change and commit ids as case-insensitive.
|
|
|
|
'format_short_change_id(id)' = 'format_short_id(id).upper()'
|
|
|
|
```
|
|
|
|
|
2023-05-06 00:12:08 +00:00
|
|
|
To get shorter prefixes for certain revisions, set `revsets.short-prefixes`:
|
|
|
|
|
|
|
|
```toml
|
2024-08-21 19:59:15 +00:00
|
|
|
# Prioritize the current bookmark
|
2023-09-05 21:58:13 +00:00
|
|
|
revsets.short-prefixes = "(main..@)::"
|
2023-05-06 00:12:08 +00:00
|
|
|
```
|
|
|
|
|
2022-10-30 08:23:45 +00:00
|
|
|
### Relative timestamps
|
2022-07-03 05:16:01 +00:00
|
|
|
|
2023-02-15 10:15:05 +00:00
|
|
|
Can be customized by the `format_timestamp()` template alias.
|
|
|
|
|
2023-01-27 01:18:08 +00:00
|
|
|
```toml
|
2023-02-15 10:15:05 +00:00
|
|
|
[template-aliases]
|
2024-02-12 07:26:19 +00:00
|
|
|
# Full timestamp in ISO 8601 format
|
2023-02-15 10:15:05 +00:00
|
|
|
'format_timestamp(timestamp)' = 'timestamp'
|
|
|
|
# Relative timestamp rendered as "x days/hours/seconds ago"
|
|
|
|
'format_timestamp(timestamp)' = 'timestamp.ago()'
|
2023-01-27 01:18:08 +00:00
|
|
|
```
|
2022-10-30 08:23:45 +00:00
|
|
|
|
2023-02-16 03:26:31 +00:00
|
|
|
`jj op log` defaults to relative timestamps. To use absolute timestamps, you
|
2023-02-19 08:05:50 +00:00
|
|
|
will need to modify the `format_time_range()` template alias.
|
2023-02-16 03:26:31 +00:00
|
|
|
|
|
|
|
```toml
|
2023-02-19 08:05:50 +00:00
|
|
|
[template-aliases]
|
2023-02-28 11:30:57 +00:00
|
|
|
'format_time_range(time_range)' = 'time_range.start() ++ " - " ++ time_range.end()'
|
2023-02-16 03:26:31 +00:00
|
|
|
```
|
|
|
|
|
2023-02-11 11:07:58 +00:00
|
|
|
### Author format
|
|
|
|
|
2023-02-15 10:15:05 +00:00
|
|
|
Can be customized by the `format_short_signature()` template alias.
|
|
|
|
|
2023-02-11 11:07:58 +00:00
|
|
|
```toml
|
2023-02-15 10:15:05 +00:00
|
|
|
[template-aliases]
|
|
|
|
# Full email address (default)
|
|
|
|
'format_short_signature(signature)' = 'signature.email()'
|
|
|
|
# Both name and email address
|
|
|
|
'format_short_signature(signature)' = 'signature'
|
|
|
|
# Username part of the email address
|
|
|
|
'format_short_signature(signature)' = 'signature.username()'
|
2023-02-11 11:07:58 +00:00
|
|
|
```
|
|
|
|
|
2024-04-04 21:07:39 +00:00
|
|
|
### Allow "large" revsets by default
|
|
|
|
|
2024-04-11 19:01:26 +00:00
|
|
|
Certain commands (such as `jj rebase`) can take multiple revset arguments, but
|
|
|
|
default to requiring each of those revsets to expand to a *single* revision.
|
|
|
|
This restriction can be overridden by prefixing a revset that the user wants to
|
|
|
|
be able to expand to more than one revision with the [`all:`
|
|
|
|
modifier](revsets.md#the-all-modifier).
|
2024-04-04 21:07:39 +00:00
|
|
|
|
2024-04-11 19:01:26 +00:00
|
|
|
Another way you can override this check is by setting
|
|
|
|
`ui.always-allow-large-revsets` to `true`. Then, `jj` will allow every one of
|
|
|
|
the revset arguments of such commands to expand to any number of revisions.
|
2024-04-04 21:07:39 +00:00
|
|
|
|
|
|
|
```toml
|
2024-04-11 19:01:26 +00:00
|
|
|
# Assume `all:` prefix before revsets whenever it would make a difference
|
2024-04-04 21:07:39 +00:00
|
|
|
ui.always-allow-large-revsets = true
|
|
|
|
```
|
|
|
|
|
2022-10-30 08:23:45 +00:00
|
|
|
## Pager
|
2022-10-18 18:07:35 +00:00
|
|
|
|
|
|
|
The default pager is can be set via `ui.pager` or the `PAGER` environment
|
2023-01-26 22:45:00 +00:00
|
|
|
variable. The priority is as follows (environment variables are marked with
|
|
|
|
a `$`):
|
2022-10-18 18:07:35 +00:00
|
|
|
|
|
|
|
`ui.pager` > `$PAGER`
|
|
|
|
|
2024-02-11 02:55:02 +00:00
|
|
|
`less -FRX` is the default pager in the absence of any other setting, except
|
|
|
|
on Windows where it is `:builtin`.
|
|
|
|
|
2024-06-09 17:18:20 +00:00
|
|
|
The special value `:builtin` enables usage of the [integrated pager called
|
|
|
|
`minus`](https://github.com/AMythicDev/minus/). See the [docs for the `minus`
|
|
|
|
pager](https://docs.rs/minus/latest/minus/#default-keybindings) for the key
|
|
|
|
bindings and some more details.
|
|
|
|
|
|
|
|
If you are using a standard Linux distro, your system likely already has
|
|
|
|
`$PAGER` set and that will be preferred over the built-in. To use the built-in:
|
2024-02-11 02:55:02 +00:00
|
|
|
|
|
|
|
```
|
|
|
|
jj config set --user ui.pager :builtin
|
|
|
|
```
|
|
|
|
|
|
|
|
It is possible the default will change to `:builtin` for all platforms in the
|
|
|
|
future.
|
2022-10-18 18:07:35 +00:00
|
|
|
|
2023-08-11 04:22:19 +00:00
|
|
|
Additionally, paging behavior can be toggled via `ui.paginate` like so:
|
|
|
|
|
|
|
|
```toml
|
2023-08-12 10:19:27 +00:00
|
|
|
# Enable pagination for commands that support it (default)
|
2023-08-11 04:22:19 +00:00
|
|
|
ui.paginate = "auto"
|
|
|
|
# Disable all pagination, equivalent to using --no-pager
|
|
|
|
ui.paginate = "never"
|
|
|
|
```
|
|
|
|
|
2023-02-17 14:38:40 +00:00
|
|
|
### Processing contents to be paged
|
|
|
|
|
|
|
|
If you'd like to pass the output through a formatter e.g.
|
|
|
|
[`diff-so-fancy`](https://github.com/so-fancy/diff-so-fancy) before piping it
|
|
|
|
through a pager you must do it using a subshell as, unlike `git` or `hg`, the
|
|
|
|
command will be executed directly. For example:
|
|
|
|
|
2023-10-02 22:24:00 +00:00
|
|
|
```toml
|
|
|
|
ui.pager = ["sh", "-c", "diff-so-fancy | less -RFX"]
|
|
|
|
```
|
2023-02-17 14:38:40 +00:00
|
|
|
|
2024-04-29 00:43:57 +00:00
|
|
|
Some formatters (like [`delta`](https://github.com/dandavison/delta)) require
|
|
|
|
git style diffs for formatting. You can configure this style of
|
|
|
|
diff as the default with the `ui.diff` setting. For example:
|
|
|
|
|
|
|
|
```toml
|
|
|
|
[ui]
|
|
|
|
pager = "delta"
|
|
|
|
|
|
|
|
[ui.diff]
|
|
|
|
format = "git"
|
|
|
|
```
|
|
|
|
|
2023-01-26 22:46:58 +00:00
|
|
|
## Aliases
|
|
|
|
|
|
|
|
You can define aliases for commands, including their arguments. For example:
|
|
|
|
|
2023-01-27 01:18:08 +00:00
|
|
|
```toml
|
2024-08-21 19:59:15 +00:00
|
|
|
# `jj l` shows commits on the working-copy commit's (anonymous) bookmark
|
|
|
|
# compared to the `main` bookmark
|
2023-09-05 21:58:13 +00:00
|
|
|
aliases.l = ["log", "-r", "(main..@):: | (main..@)-"]
|
2023-01-27 01:18:08 +00:00
|
|
|
```
|
2023-01-26 22:46:58 +00:00
|
|
|
|
2022-10-30 08:23:45 +00:00
|
|
|
## Editor
|
2022-07-03 05:16:01 +00:00
|
|
|
|
2023-01-26 22:45:00 +00:00
|
|
|
The default editor is set via `ui.editor`, though there are several places to
|
|
|
|
set it. The priority is as follows (environment variables are marked with
|
|
|
|
a `$`):
|
2022-07-03 05:16:01 +00:00
|
|
|
|
|
|
|
`$JJ_EDITOR` > `ui.editor` > `$VISUAL` > `$EDITOR`
|
|
|
|
|
2023-08-10 15:50:25 +00:00
|
|
|
Pico is the default editor (Notepad on Windows) in the absence of any other
|
|
|
|
setting, but you could set it explicitly too.
|
2022-07-03 05:16:01 +00:00
|
|
|
|
2023-01-27 01:18:08 +00:00
|
|
|
```toml
|
|
|
|
ui.editor = "pico"
|
|
|
|
```
|
2022-07-03 05:16:01 +00:00
|
|
|
|
|
|
|
To use NeoVim instead:
|
|
|
|
|
2023-01-27 01:18:08 +00:00
|
|
|
```toml
|
|
|
|
ui.editor = "nvim"
|
|
|
|
```
|
2022-07-03 05:16:01 +00:00
|
|
|
|
|
|
|
For GUI editors you possibly need to use a `-w` or `--wait`. Some examples:
|
|
|
|
|
2023-01-27 01:18:08 +00:00
|
|
|
```toml
|
|
|
|
ui.editor = "code -w" # VS Code
|
2024-05-28 02:24:14 +00:00
|
|
|
ui.editor = "code.cmd -w" # VS Code on Windows
|
2023-01-27 01:18:08 +00:00
|
|
|
ui.editor = "bbedit -w" # BBEdit
|
|
|
|
ui.editor = "subl -n -w" # Sublime Text
|
|
|
|
ui.editor = "mate -w" # TextMate
|
|
|
|
ui.editor = ["C:/Program Files/Notepad++/notepad++.exe",
|
2023-01-27 17:16:06 +00:00
|
|
|
"-multiInst", "-notabbar", "-nosession", "-noPlugin"] # Notepad++
|
2023-01-27 01:18:08 +00:00
|
|
|
ui.editor = "idea --temp-project --wait" #IntelliJ
|
|
|
|
```
|
2022-07-03 05:16:01 +00:00
|
|
|
|
|
|
|
Obviously, you would only set one line, don't copy them all in!
|
|
|
|
|
2022-10-30 08:23:45 +00:00
|
|
|
## Editing diffs
|
2022-07-03 05:16:01 +00:00
|
|
|
|
2023-08-29 21:13:36 +00:00
|
|
|
The `ui.diff-editor` setting affects the tool used for editing diffs (e.g. `jj
|
2024-03-07 23:26:45 +00:00
|
|
|
split`, `jj squash -i`). The default is the special value `:builtin`, which
|
2024-02-04 23:45:54 +00:00
|
|
|
launches a built-in TUI tool (known as [scm-diff-editor]) to edit the diff in
|
|
|
|
your terminal.
|
|
|
|
|
|
|
|
[scm-diff-editor]: https://github.com/arxanas/scm-record?tab=readme-ov-file#scm-diff-editor
|
2023-02-06 10:38:51 +00:00
|
|
|
|
2023-02-06 11:08:26 +00:00
|
|
|
`jj` makes the following substitutions:
|
2023-02-06 10:38:51 +00:00
|
|
|
|
|
|
|
- `$left` and `$right` are replaced with the paths to the left and right
|
|
|
|
directories to diff respectively.
|
|
|
|
|
|
|
|
If no arguments are specified, `["$left", "$right"]` are set by default.
|
2022-07-03 05:16:01 +00:00
|
|
|
|
|
|
|
For example:
|
|
|
|
|
2023-01-27 01:18:08 +00:00
|
|
|
```toml
|
2023-02-06 10:38:51 +00:00
|
|
|
# Use merge-tools.kdiff3.edit-args
|
|
|
|
ui.diff-editor = "kdiff3"
|
|
|
|
# Specify edit-args inline
|
|
|
|
ui.diff-editor = ["kdiff3", "--merge", "$left", "$right"]
|
2023-01-27 01:18:08 +00:00
|
|
|
```
|
2022-07-03 05:16:01 +00:00
|
|
|
|
2023-02-06 10:38:51 +00:00
|
|
|
If `ui.diff-editor` consists of a single word, e.g. `"kdiff3"`, the arguments
|
|
|
|
will be read from the following config keys.
|
2022-07-03 05:16:01 +00:00
|
|
|
|
2023-01-27 01:18:08 +00:00
|
|
|
```toml
|
|
|
|
# merge-tools.kdiff3.program = "kdiff3" # Defaults to the name of the tool if not specified
|
2023-02-06 10:38:51 +00:00
|
|
|
merge-tools.kdiff3.edit-args = [
|
|
|
|
"--merge", "--cs", "CreateBakFiles=0", "$left", "$right"]
|
2023-01-27 01:18:08 +00:00
|
|
|
```
|
2022-10-31 01:29:26 +00:00
|
|
|
|
2023-08-07 23:40:10 +00:00
|
|
|
### Experimental 3-pane diff editing
|
|
|
|
|
2024-04-06 22:47:44 +00:00
|
|
|
We offer two special "3-pane" diff editor configs:
|
|
|
|
|
|
|
|
- `meld-3`, which requires installing [Meld](https://meldmerge.org/), and
|
|
|
|
- `diffedit3`, which requires installing [`diffedit3`](https://github.com/ilyagr/diffedit3/releases).
|
|
|
|
|
|
|
|
`Meld` is a graphical application that is recommended, but can be difficult to
|
|
|
|
install in some situations. `diffedit3` is designed to be easy to install and to
|
|
|
|
be usable in environments where Meld is difficult to use (e.g. over SSH via port
|
|
|
|
forwarding). `diffedit3` starts a local server that can be accessed via a web
|
|
|
|
browser, similarly to [Jupyter](https://jupyter.org/).
|
|
|
|
|
|
|
|
There is also the `diffedit3-ssh` which is similar to `diffedit3` but does not
|
|
|
|
try to open the web browser pointing to the local server (the URL
|
|
|
|
printed to the terminal) automatically. `diffedit3-ssh` also always uses ports in between
|
|
|
|
17376-17380 and fails if they are all busy. This can be useful when working
|
|
|
|
over SSH. Open the fold below for more details of how to set that up.
|
|
|
|
|
|
|
|
<details>
|
|
|
|
<summary> Tips for using `diffedit3-ssh` over SSH </summary>
|
|
|
|
|
|
|
|
To use `diffedit3` over SSH, you need to set up port forwarding. One way to do
|
|
|
|
this is to start SSH as follows (copy-paste the relevant lines):
|
|
|
|
|
|
|
|
```shell
|
|
|
|
ssh -L 17376:localhost:17376 \
|
|
|
|
-L 17377:localhost:17377 \
|
|
|
|
-L 17378:localhost:17378 \
|
|
|
|
-L 17379:localhost:17379 \
|
|
|
|
-L 17380:localhost:17380 \
|
|
|
|
myhost.example.com
|
|
|
|
```
|
|
|
|
|
|
|
|
`diffedit3-ssh` is set up to use these 5 ports by default. Usually, only the
|
|
|
|
first of them will be used. The rest are used if another program happens to use
|
|
|
|
one of them, or if you run multiple instances of `diffedit3` at the same time.
|
|
|
|
|
|
|
|
Another way is to add a snippet to `~/.ssh/config`:
|
|
|
|
|
|
|
|
```
|
|
|
|
Host myhost
|
|
|
|
User myself
|
|
|
|
Hostname myhost.example.com
|
|
|
|
LocalForward 17376 localhost:17376
|
|
|
|
LocalForward 17377 localhost:17377
|
|
|
|
LocalForward 17378 localhost:17378
|
|
|
|
LocalForward 17379 localhost:17379
|
|
|
|
LocalForward 17380 localhost:17380
|
|
|
|
```
|
|
|
|
|
|
|
|
With that configuration, you should be able to simply `ssh myhost`.
|
|
|
|
|
|
|
|
</details>
|
|
|
|
|
|
|
|
|
|
|
|
Setting either `ui.diff-editor = "meld-3"` or `ui.diff-editor = "diffedit3"`
|
|
|
|
will result in the diff editor showing 3 panes: the diff on the left and right,
|
|
|
|
and an editing pane in the middle. This allow you to see both sides of the
|
|
|
|
original diff while editing.
|
|
|
|
|
|
|
|
If you use `ui.diff-editor = "meld-3"`, note that you can still get the 2-pane
|
|
|
|
Meld view using `jj diff --tool meld`. `diffedit3` has a button you can use to
|
|
|
|
switch to a 2-pane view.
|
|
|
|
|
|
|
|
To configure other diff editors in this way, you can include `$output` together
|
|
|
|
with `$left` and `$right` in `merge-tools.TOOL.edit-args`. `jj` will replace
|
|
|
|
`$output` with the directory where the diff editor will be expected to put the
|
|
|
|
result of the user's edits. Initially, the contents of `$output` will be the
|
|
|
|
same as the contents of `$right`.
|
2023-08-07 23:40:10 +00:00
|
|
|
|
2023-06-07 02:33:32 +00:00
|
|
|
### `JJ-INSTRUCTIONS`
|
|
|
|
|
|
|
|
When editing a diff, jj will include a synthetic file called `JJ-INSTRUCTIONS`
|
|
|
|
in the diff with instructions on how to edit the diff. Any changes you make to
|
|
|
|
this file will be ignored. To suppress the creation of this file, set
|
|
|
|
`ui.diff-instructions = false`.
|
|
|
|
|
2022-12-18 00:36:15 +00:00
|
|
|
### Using Vim as a diff editor
|
|
|
|
|
2023-01-26 22:45:00 +00:00
|
|
|
Using `ui.diff-editor = "vimdiff"` is possible but not recommended. For a better
|
2023-12-18 04:05:17 +00:00
|
|
|
experience, you can follow [instructions from the Wiki] to configure the
|
|
|
|
[DirDiff Vim plugin] and/or the [vimtabdiff Python script].
|
2022-12-18 00:36:15 +00:00
|
|
|
|
2023-12-18 04:05:17 +00:00
|
|
|
[instructions from the Wiki]: https://github.com/martinvonz/jj/wiki/Vim#using-vim-as-a-diff-tool
|
2023-01-26 22:45:00 +00:00
|
|
|
|
2023-09-07 16:36:08 +00:00
|
|
|
[DirDiff Vim plugin]: https://github.com/will133/vim-dirdiff
|
|
|
|
[vimtabdiff Python script]: https://github.com/balki/vimtabdiff
|
2022-11-26 01:33:24 +00:00
|
|
|
|
2022-10-30 08:23:45 +00:00
|
|
|
## 3-way merge tools for conflict resolution
|
|
|
|
|
2023-01-26 22:45:00 +00:00
|
|
|
The `ui.merge-editor` key specifies the tool used for three-way merge tools
|
|
|
|
by `jj resolve`. For example:
|
2022-10-30 08:23:45 +00:00
|
|
|
|
2023-01-27 01:18:08 +00:00
|
|
|
```toml
|
2023-02-05 07:41:28 +00:00
|
|
|
# Use merge-tools.meld.merge-args
|
2024-08-09 08:11:24 +00:00
|
|
|
ui.merge-editor = "meld" # Or "vscode" or "vscodium" or "kdiff3" or "vimdiff"
|
2023-02-05 07:41:28 +00:00
|
|
|
# Specify merge-args inline
|
|
|
|
ui.merge-editor = ["meld", "$left", "$base", "$right", "-o", "$output"]
|
2023-01-27 01:18:08 +00:00
|
|
|
```
|
2022-10-30 08:23:45 +00:00
|
|
|
|
2024-08-09 08:11:24 +00:00
|
|
|
The "vscode", "vscodium", "meld", "kdiff3", and "vimdiff" tools can be used out of the box,
|
2023-10-25 03:36:31 +00:00
|
|
|
as long as they are installed.
|
|
|
|
|
|
|
|
Using VS Code as a merge tool works well with VS Code's [Remote
|
|
|
|
Development](https://code.visualstudio.com/docs/remote/remote-overview)
|
|
|
|
functionality, as long as `jj` is called from VS Code's terminal.
|
|
|
|
|
|
|
|
### Setting up a custom merge tool
|
2022-10-30 08:23:45 +00:00
|
|
|
|
2023-01-26 22:45:00 +00:00
|
|
|
To use a different tool named `TOOL`, the arguments to pass to the tool MUST be
|
2023-02-05 07:41:28 +00:00
|
|
|
specified either inline or in the `merge-tools.TOOL.merge-args` key. As an
|
|
|
|
example of how to set this key and other tool configuration options, here is
|
|
|
|
the out-of-the-box configuration of the three default tools. (There is no need
|
|
|
|
to copy it to your config file verbatim, but you are welcome to customize it.)
|
2022-10-30 08:23:45 +00:00
|
|
|
|
2023-01-27 01:18:08 +00:00
|
|
|
```toml
|
|
|
|
# merge-tools.kdiff3.program = "kdiff3" # Defaults to the name of the tool if not specified
|
|
|
|
merge-tools.kdiff3.merge-args = ["$base", "$left", "$right", "-o", "$output", "--auto"]
|
2023-01-27 17:16:06 +00:00
|
|
|
merge-tools.meld.merge-args = ["$left", "$base", "$right", "-o", "$output", "--auto-merge"]
|
2022-10-30 08:23:45 +00:00
|
|
|
|
2023-01-27 01:18:08 +00:00
|
|
|
merge-tools.vimdiff.merge-args = ["-f", "-d", "$output", "-M",
|
2023-01-27 17:16:06 +00:00
|
|
|
"$left", "$base", "$right",
|
|
|
|
"-c", "wincmd J", "-c", "set modifiable",
|
|
|
|
"-c", "set write"]
|
2023-01-27 01:18:08 +00:00
|
|
|
merge-tools.vimdiff.program = "vim"
|
|
|
|
merge-tools.vimdiff.merge-tool-edits-conflict-markers = true # See below for an explanation
|
|
|
|
```
|
2022-10-30 08:23:45 +00:00
|
|
|
|
2023-02-06 11:08:26 +00:00
|
|
|
`jj` makes the following substitutions:
|
2022-10-30 08:23:45 +00:00
|
|
|
|
2023-01-26 22:45:00 +00:00
|
|
|
- `$output` (REQUIRED) is replaced with the name of the file that the merge tool
|
|
|
|
should output. `jj` will read this file after the merge tool exits.
|
2022-10-30 08:23:45 +00:00
|
|
|
|
2023-01-26 22:45:00 +00:00
|
|
|
- `$left` and `$right` are replaced with the paths to two files containing the
|
|
|
|
content of each side of the conflict.
|
2022-10-30 08:23:45 +00:00
|
|
|
|
2023-01-26 22:45:00 +00:00
|
|
|
- `$base` is replaced with the path to a file containing the contents of the
|
|
|
|
conflicted file in the last common ancestor of the two sides of the conflict.
|
2022-10-30 08:23:45 +00:00
|
|
|
|
|
|
|
### Editing conflict markers with a tool or a text editor
|
|
|
|
|
2023-01-26 22:45:00 +00:00
|
|
|
By default, the merge tool starts with an empty output file. If the tool puts
|
|
|
|
anything into the output file, and exits with the 0 exit code,
|
|
|
|
`jj` assumes that the conflict is fully resolved. This is appropriate for most
|
|
|
|
graphical merge tools.
|
2022-10-30 08:23:45 +00:00
|
|
|
|
2023-01-26 22:45:00 +00:00
|
|
|
Some tools (e.g. `vimdiff`) can present a multi-way diff but don't resolve
|
|
|
|
conflict themselves. When using such tools, `jj`
|
|
|
|
can help you by populating the output file with conflict markers before starting
|
|
|
|
the merge tool (instead of leaving the output file empty and letting the merge
|
|
|
|
tool fill it in). To do that, set the
|
2022-10-30 08:23:45 +00:00
|
|
|
`merge-tools.vimdiff.merge-tool-edits-conflict-markers = true` option.
|
|
|
|
|
2023-01-26 22:45:00 +00:00
|
|
|
With this option set, if the output file still contains conflict markers after
|
|
|
|
the conflict is done, `jj` assumes that the conflict was only partially resolved
|
|
|
|
and parses the conflict markers to get the new state of the conflict. The
|
|
|
|
conflict is considered fully resolved when there are no conflict markers left.
|
2022-10-30 08:23:45 +00:00
|
|
|
|
2024-07-10 23:22:08 +00:00
|
|
|
## Code formatting and other file content transformations
|
|
|
|
|
|
|
|
The `jj fix` command allows you to efficiently rewrite files in complex commit
|
|
|
|
graphs with no risk of introducing conflicts, using tools like `clang-format` or
|
|
|
|
`prettier`. The tools run as subprocesses that take file content on standard
|
|
|
|
input and repeat it, with any desired changes, on standard output. The file is
|
|
|
|
only rewritten if the subprocess produces a successful exit code.
|
|
|
|
|
|
|
|
### Enforce coding style rules
|
|
|
|
|
|
|
|
Suppose you want to use `clang-format` to format your `*.c` and `*.h` files,
|
|
|
|
as well as sorting their `#include` directives.
|
|
|
|
|
|
|
|
`jj fix` provides the file content anonymously on standard input, but the name
|
|
|
|
of the file being formatted may be important for include sorting or other output
|
|
|
|
like error messages. To address this, you can use the `$path` substitution to
|
|
|
|
provide the name of the file in a command argument.
|
|
|
|
|
|
|
|
```toml
|
|
|
|
[fix.tools.clang-format]
|
|
|
|
command = ["/usr/bin/clang-format", "--sort-includes", "--assume-filename=$path"]
|
|
|
|
patterns = ["glob:'**/*.c'",
|
|
|
|
"glob:'**/*.h'"]
|
|
|
|
```
|
|
|
|
|
|
|
|
### Sort and remove duplicate lines from a file
|
|
|
|
|
|
|
|
`jj fix` can also be used with tools that are not considered code formatters.
|
|
|
|
|
|
|
|
Suppose you have a list of words in a text file in your repository, and you want
|
|
|
|
to keep the file sorted alphabetically and remove any duplicate words.
|
|
|
|
|
|
|
|
```toml
|
|
|
|
[fix.tools.sort-word-list]
|
|
|
|
command = ["sort", "-u"]
|
|
|
|
patterns = ["word_list.txt"]
|
|
|
|
```
|
|
|
|
|
|
|
|
### Execution order of tools
|
|
|
|
|
|
|
|
If two or more tools affect the same file, they are executed in the ascending
|
|
|
|
lexicographical order of their configured names. This will remain as a tie
|
|
|
|
breaker if other ordering mechanisms are introduced in the future. If you use
|
|
|
|
numbers in tool names to control execution order, remember to include enough
|
|
|
|
leading zeros so that, for example, `09` sorts before `10`.
|
|
|
|
|
|
|
|
Suppose you want to keep only the 10 smallest numbers in a text file that
|
|
|
|
contains one number on each line. This can be accomplished with `sort` and
|
|
|
|
`head`, but execution order is important.
|
|
|
|
|
|
|
|
```toml
|
|
|
|
[fix.tools.1-sort-numbers-file]
|
|
|
|
command = ["sort", "-n"]
|
|
|
|
patterns = ["numbers.txt"]
|
|
|
|
|
|
|
|
[fix.tools.2-truncate-numbers-file]
|
|
|
|
command = ["head", "-n", "10"]
|
|
|
|
patterns = ["numbers.txt"]
|
|
|
|
```
|
|
|
|
|
2024-02-13 10:40:37 +00:00
|
|
|
## Commit Signing
|
|
|
|
|
2024-09-13 05:25:47 +00:00
|
|
|
`jj` can be configured to sign and verify the commits it creates using either
|
2024-02-13 10:40:37 +00:00
|
|
|
GnuPG or SSH signing keys.
|
|
|
|
|
|
|
|
To do this you need to configure a signing backend.
|
|
|
|
|
2024-09-06 00:27:49 +00:00
|
|
|
Setting the backend to `"none"` disables signing.
|
|
|
|
|
2024-02-13 10:40:37 +00:00
|
|
|
### GnuPG Signing
|
|
|
|
|
|
|
|
```toml
|
|
|
|
[signing]
|
|
|
|
sign-all = true
|
|
|
|
backend = "gpg"
|
|
|
|
key = "4ED556E9729E000F"
|
2024-03-13 16:39:15 +00:00
|
|
|
## You can set `key` to anything accepted by `gpg -u`
|
|
|
|
# key = "signing@example.com"
|
2024-02-13 10:40:37 +00:00
|
|
|
```
|
|
|
|
|
|
|
|
By default the gpg backend will look for a `gpg` binary on your path. If you want
|
|
|
|
to change the program used or specify a path to `gpg` explicitly you can set:
|
|
|
|
|
|
|
|
```toml
|
|
|
|
signing.backends.gpg.program = "gpg2"
|
|
|
|
```
|
|
|
|
|
|
|
|
Also by default the gpg backend will ignore key expiry when verifying commit signatures.
|
|
|
|
To consider expired keys as invalid you can set:
|
|
|
|
|
|
|
|
```toml
|
|
|
|
signing.backends.gpg.allow-expired-keys = false
|
|
|
|
```
|
|
|
|
|
|
|
|
### SSH Signing
|
|
|
|
|
|
|
|
```toml
|
|
|
|
[signing]
|
|
|
|
sign-all = true
|
|
|
|
backend = "ssh"
|
|
|
|
key = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIGj+J6N6SO+4P8dOZqfR1oiay2yxhhHnagH52avUqw5h"
|
2024-03-13 16:39:15 +00:00
|
|
|
## You can also use a path instead of embedding the key
|
2024-08-12 16:39:35 +00:00
|
|
|
# key = "~/.ssh/id_for_signing.pub"
|
2024-02-13 10:40:37 +00:00
|
|
|
```
|
|
|
|
|
|
|
|
By default the ssh backend will look for a `ssh-keygen` binary on your path. If you want
|
|
|
|
to change the program used or specify a path to `ssh-keygen` explicitly you can set:
|
|
|
|
|
|
|
|
```toml
|
|
|
|
signing.backends.ssh.program = "/path/to/ssh-keygen"
|
|
|
|
```
|
|
|
|
|
|
|
|
When verifying commit signatures the ssh backend needs to be provided with an allowed-signers
|
|
|
|
file containing the public keys of authors whose signatures you want to be able to verify.
|
|
|
|
|
2024-09-13 05:25:47 +00:00
|
|
|
You can find the format for this file in the
|
|
|
|
[ssh-keygen man page](https://man.openbsd.org/ssh-keygen#ALLOWED_SIGNERS). This can be provided
|
2024-02-13 10:40:37 +00:00
|
|
|
as follows:
|
|
|
|
|
|
|
|
```toml
|
|
|
|
signing.backends.ssh.allowed-signers = "/path/to/allowed-signers"
|
|
|
|
```
|
|
|
|
|
2022-12-13 00:18:19 +00:00
|
|
|
## Git settings
|
|
|
|
|
2024-02-08 00:32:41 +00:00
|
|
|
### Default remotes for `jj git fetch` and `jj git push`
|
|
|
|
|
|
|
|
By default, if a single remote exists it is used for `jj git fetch` and `jj git
|
|
|
|
push`; however if multiple remotes exist, the default remote is assumed to be
|
|
|
|
named `"origin"`, just like in Git. Sometimes this is undesirable, e.g. when you
|
|
|
|
want to fetch from a different remote than you push to, such as a GitHub fork.
|
|
|
|
|
|
|
|
To change this behavior, you can modify the [repository
|
|
|
|
configuration](#config-files-and-toml) variable `git.fetch`, which can be a
|
|
|
|
single remote, or a list of remotes to fetch from multiple places:
|
|
|
|
|
2024-02-09 18:04:15 +00:00
|
|
|
```sh
|
2024-02-08 00:32:41 +00:00
|
|
|
jj config set --repo git.fetch "upstream"
|
|
|
|
jj config set --repo git.fetch '["origin", "upstream"]'
|
|
|
|
```
|
|
|
|
|
|
|
|
Similarly, you can also set the variable `git.push` to cause `jj git push` to
|
|
|
|
push to a different remote:
|
|
|
|
|
2024-02-09 18:04:15 +00:00
|
|
|
```sh
|
2024-02-08 00:32:41 +00:00
|
|
|
jj config set --repo git.push "github"
|
|
|
|
```
|
|
|
|
|
2024-02-09 18:04:15 +00:00
|
|
|
Note that unlike `git.fetch`, `git.push` can currently only be a single remote.
|
|
|
|
This is not a hard limitation, and could be changed in the future if there is
|
|
|
|
demand.
|
|
|
|
|
2024-08-21 19:59:15 +00:00
|
|
|
### Automatic local bookmark creation
|
2022-12-13 00:18:19 +00:00
|
|
|
|
2024-08-21 19:59:15 +00:00
|
|
|
When `jj` imports a new remote-tracking bookmark from Git, it can also create a
|
|
|
|
local bookmark with the same name. This feature is disabled by default because it
|
2023-12-16 10:01:44 +00:00
|
|
|
may be undesirable in some repositories, e.g.:
|
2022-12-13 00:18:19 +00:00
|
|
|
|
2024-08-21 19:59:15 +00:00
|
|
|
- There is a remote with a lot of historical bookmarks that you don't
|
2022-12-13 00:18:19 +00:00
|
|
|
want to be exported to the co-located Git repo.
|
2024-08-21 19:59:15 +00:00
|
|
|
- There are multiple remotes with conflicting views of that bookmark,
|
2022-12-13 00:18:19 +00:00
|
|
|
resulting in an unhelpful conflicted state.
|
|
|
|
|
2024-08-21 19:59:15 +00:00
|
|
|
You can enable this behavior by setting `git.auto-local-bookmark` like so,
|
2022-12-13 00:18:19 +00:00
|
|
|
|
2023-10-12 09:22:19 +00:00
|
|
|
```toml
|
2024-08-21 19:59:15 +00:00
|
|
|
git.auto-local-bookmark = true
|
2023-10-12 09:22:19 +00:00
|
|
|
```
|
2022-12-13 00:18:19 +00:00
|
|
|
|
2024-08-21 19:59:15 +00:00
|
|
|
This setting is applied only to new remote bookmarks. Existing remote bookmarks
|
|
|
|
can be tracked individually by using `jj bookmark track`/`untrack` commands.
|
2023-10-12 18:29:53 +00:00
|
|
|
|
|
|
|
```shell
|
2024-08-21 19:59:15 +00:00
|
|
|
# import feature1 bookmark and start tracking it
|
|
|
|
jj bookmark track feature1@origin
|
|
|
|
# delete local gh-pages bookmark and stop tracking it
|
|
|
|
jj bookmark delete gh-pages
|
|
|
|
jj bookmark untrack gh-pages@upstream
|
2023-10-12 18:29:53 +00:00
|
|
|
```
|
|
|
|
|
2023-11-05 05:15:41 +00:00
|
|
|
### Abandon commits that became unreachable in Git
|
|
|
|
|
|
|
|
By default, when `jj` imports refs from Git, it will look for commits that used
|
|
|
|
to be [reachable][reachable] but no longer are reachable. Those commits will
|
|
|
|
then be abandoned, and any descendant commits will be rebased off of them (as
|
|
|
|
usual when commits are abandoned). You can disable this behavior and instead
|
|
|
|
leave the Git-unreachable commits in your repo by setting:
|
|
|
|
|
|
|
|
```toml
|
|
|
|
git.abandon-unreachable-commits = false
|
|
|
|
```
|
|
|
|
|
|
|
|
[reachable]: https://git-scm.com/docs/gitglossary/#Documentation/gitglossary.txt-aiddefreachableareachable
|
|
|
|
|
2024-08-21 19:59:15 +00:00
|
|
|
### Prefix for generated bookmarks on push
|
2023-08-02 21:45:35 +00:00
|
|
|
|
2024-08-21 19:59:15 +00:00
|
|
|
`jj git push --change` generates bookmark names with a prefix of "push-" by
|
|
|
|
default. You can pick a different prefix by setting `git.push-bookmark-prefix`. For
|
2023-08-02 21:45:35 +00:00
|
|
|
example:
|
|
|
|
|
2024-08-21 19:59:15 +00:00
|
|
|
git.push-bookmark-prefix = "martinvonz/push-"
|
2023-08-02 21:45:35 +00:00
|
|
|
|
2024-07-05 21:47:46 +00:00
|
|
|
### Set of private commits
|
|
|
|
|
|
|
|
You can configure the set of private commits by setting `git.private-commits` to
|
|
|
|
a revset. The value is a revset of commits that Jujutsu will refuse to push. If
|
|
|
|
unset, all commits are eligible to be pushed.
|
|
|
|
|
|
|
|
```toml
|
|
|
|
# Prevent pushing work in progress or anything explicitly labeled "private"
|
|
|
|
git.private-commits = "description(glob:'wip:*') | description(glob:'private:*')"
|
|
|
|
```
|
|
|
|
|
|
|
|
If a commit is in `git.private-commits` but is already on the remote, then it is
|
|
|
|
not considered a private commit. Commits that are immutable are also excluded
|
|
|
|
from the private set.
|
|
|
|
|
|
|
|
Private commits prevent their descendants from being pushed, since doing so
|
|
|
|
would require pushing the private commit as well.
|
|
|
|
|
2023-07-08 09:23:09 +00:00
|
|
|
## Filesystem monitor
|
|
|
|
|
|
|
|
In large repositories, it may be beneficial to use a "filesystem monitor" to
|
|
|
|
track changes to the working copy. This allows `jj` to take working copy
|
|
|
|
snapshots without having to rescan the entire working copy.
|
|
|
|
|
2024-04-11 05:29:50 +00:00
|
|
|
This is governed by the `core.fsmonitor` option. Currently, the valid values are
|
|
|
|
`"none"` or `"watchman"`.
|
|
|
|
|
2023-07-08 09:23:09 +00:00
|
|
|
### Watchman
|
|
|
|
|
|
|
|
To configure the Watchman filesystem monitor, set
|
|
|
|
`core.fsmonitor = "watchman"`. Ensure that you have [installed the Watchman
|
2023-09-07 16:36:08 +00:00
|
|
|
executable on your system](https://facebook.github.io/watchman/docs/install).
|
2023-07-08 09:23:09 +00:00
|
|
|
|
2024-06-15 20:50:37 +00:00
|
|
|
You can configure `jj` to use watchman triggers to automatically create
|
|
|
|
snapshots on filestem changes by setting
|
|
|
|
`core.watchman.register_snapshot_trigger = true`.
|
|
|
|
|
2024-03-31 05:47:07 +00:00
|
|
|
You can check whether Watchman is enabled and whether it is installed correctly
|
|
|
|
using `jj debug watchman status`.
|
2023-07-08 09:23:09 +00:00
|
|
|
|
2024-03-28 20:45:31 +00:00
|
|
|
## Snapshot settings
|
|
|
|
|
|
|
|
### Maximum size for new files
|
|
|
|
|
|
|
|
By default, as an anti-footgun measure, `jj` will refuse to add new files to the
|
|
|
|
snapshot that are larger than a certain size; the default is 1MiB. This can be
|
|
|
|
changed by setting `snapshot.max-new-file-size` to a different value. For
|
|
|
|
example:
|
|
|
|
|
|
|
|
```toml
|
|
|
|
snapshot.max-new-file-size = "10MiB"
|
|
|
|
# the following is equivalent
|
|
|
|
snapshot.max-new-file-size = 10485760
|
|
|
|
```
|
|
|
|
|
|
|
|
The value can be specified using a human readable string with typical suffixes;
|
|
|
|
`B`, `MiB`, `GB`, etc. By default, if no suffix is provided, or the value is a
|
|
|
|
raw integer literal, the value is interpreted as if it were specified in bytes.
|
|
|
|
|
|
|
|
Files that already exist in the working copy are not subject to this limit.
|
|
|
|
|
|
|
|
Setting this value to zero will disable the limit entirely.
|
|
|
|
|
2024-02-01 04:53:23 +00:00
|
|
|
## Ways to specify `jj` config: details
|
|
|
|
|
|
|
|
### User config file
|
|
|
|
|
|
|
|
An easy way to find the user config file is:
|
|
|
|
|
|
|
|
```bash
|
|
|
|
jj config path --user
|
|
|
|
```
|
|
|
|
|
|
|
|
The rest of this section covers the details of where this file can be located.
|
2022-10-31 01:29:26 +00:00
|
|
|
|
2023-06-28 21:43:22 +00:00
|
|
|
On all platforms, the user's global `jj` configuration file is located at either
|
|
|
|
`~/.jjconfig.toml` (where `~` represents `$HOME` on Unix-likes, or
|
|
|
|
`%USERPROFILE%` on Windows) or in a platform-specific directory. The
|
|
|
|
platform-specific location is recommended for better integration with platform
|
|
|
|
services. It is an error for both of these files to exist.
|
2023-04-12 19:56:59 +00:00
|
|
|
|
|
|
|
| Platform | Value | Example |
|
|
|
|
| :------- | :------------------------------------------------- | :-------------------------------------------------------- |
|
|
|
|
| Linux | `$XDG_CONFIG_HOME/jj/config.toml` | `/home/alice/.config/jj/config.toml` |
|
|
|
|
| macOS | `$HOME/Library/Application Support/jj/config.toml` | `/Users/Alice/Library/Application Support/jj/config.toml` |
|
|
|
|
| Windows | `{FOLDERID_RoamingAppData}\jj\config.toml` | `C:\Users\Alice\AppData\Roaming\jj\config.toml` |
|
2022-10-31 01:29:26 +00:00
|
|
|
|
2023-01-28 07:35:45 +00:00
|
|
|
The location of the `jj` config file can also be overridden with the
|
2023-01-26 22:45:00 +00:00
|
|
|
`JJ_CONFIG` environment variable. If it is not empty, it should contain the path
|
|
|
|
to a TOML file that will be used instead of any configuration file in the
|
|
|
|
default locations. For example,
|
2022-10-31 01:29:26 +00:00
|
|
|
|
2023-01-27 01:18:08 +00:00
|
|
|
```shell
|
|
|
|
env JJ_CONFIG=/dev/null jj log # Ignores any settings specified in the config file.
|
|
|
|
```
|
2022-10-31 01:29:26 +00:00
|
|
|
|
2024-02-01 04:53:23 +00:00
|
|
|
### Specifying config on the command-line
|
|
|
|
|
2023-01-26 22:45:00 +00:00
|
|
|
You can use one or more `--config-toml` options on the command line to specify
|
|
|
|
additional configuration settings. This overrides settings defined in config
|
|
|
|
files or environment variables. For example,
|
2022-10-31 01:29:26 +00:00
|
|
|
|
2023-01-27 01:18:08 +00:00
|
|
|
```shell
|
2023-08-14 00:51:15 +00:00
|
|
|
jj --config-toml='ui.color="always"' --config-toml='ui.diff-editor="kdiff3"' split
|
2023-01-27 01:18:08 +00:00
|
|
|
```
|
2022-10-31 01:29:26 +00:00
|
|
|
|
2023-01-26 22:45:00 +00:00
|
|
|
Config specified this way must be valid TOML. In particular, string values must
|
|
|
|
be surrounded by quotes. To pass these quotes to `jj`, most shells require
|
|
|
|
surrounding those quotes with single quotes as shown above.
|
2022-10-31 01:29:26 +00:00
|
|
|
|
|
|
|
In `sh`-compatible shells, `--config-toml` can be used to merge entire TOML
|
|
|
|
files with the config specified in `.jjconfig.toml`:
|
|
|
|
|
2023-01-27 01:18:08 +00:00
|
|
|
```shell
|
|
|
|
jj --config-toml="$(cat extra-config.toml)" log
|
|
|
|
```
|