Skip to content

Commit

Permalink
cli: include untracked remote branches in default immutable_heads()
Browse files Browse the repository at this point in the history
I used to use "remote_branches() & ~mine()" to exclude "their" branches from
the default log, and I don't think that's uncommon requirement. Suppose
untracked branches are usually read-only, it's probably okay to make them
immutable by default.
  • Loading branch information
yuja committed Jul 15, 2024
1 parent 692c996 commit ea3a574
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 14 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@ to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
* `jj backout --revision` has been renamed to `jj backout --revisions`.
The short alias `-r` is still supported.

* [The default `immutable_heads()` set](docs/config.md#set-of-immutable-commits)
now includes `untracked_remote_branches()` with the assumption that untracked
branches aren't managed by you. Therefore, untracked branches are no longer
displayed in `jj log` by default.

### Deprecations

### New features
Expand Down
2 changes: 1 addition & 1 deletion cli/src/config-schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,7 @@
"immutable_heads()": {
"type": "string",
"description": "Revisions to consider immutable. Ancestors of these are also considered immutable. The root commit is always considered immutable.",
"default": "trunk() | tags()"
"default": "trunk() | tags() | untracked_remote_branches()"
}
},
"additionalProperties": {
Expand Down
2 changes: 1 addition & 1 deletion cli/src/config/revsets.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@ latest(
)
'''

'immutable_heads()' = 'trunk() | tags()'
'immutable_heads()' = 'trunk() | tags() | untracked_remote_branches()'
'immutable()' = '::(immutable_heads() | root())'
'mutable()' = '~immutable()'
8 changes: 4 additions & 4 deletions docs/config.md
Original file line number Diff line number Diff line change
Expand Up @@ -224,10 +224,10 @@ diff-invocation-mode = "file-by-file"

### Set of immutable commits

You can configure the set of immutable commits via `revset-aliases."immutable_heads()"`.
The default set of immutable heads is `trunk() | tags()`. For example, to
prevent rewriting commits on `main@origin` and commits authored by other
users:
You can configure the set of immutable commits via
`revset-aliases."immutable_heads()"`. The default set of immutable heads is
`trunk() | tags() | untracked_remote_branches()`. For example, to prevent
rewriting commits on `main@origin` and commits authored by other users:

```toml
# The `main.. &` bit is an optimization to scan for non-`mine()` commits only
Expand Down
7 changes: 0 additions & 7 deletions docs/contributing.md
Original file line number Diff line number Diff line change
Expand Up @@ -117,13 +117,6 @@ installer options are fine), clone the repository, and use `cargo build`
`cargo test --workspace`. If you are preparing a PR, there are some additional
recommended steps.

You will probably also want to make the `gh-pages` branch immutable (and thereby
hidden from the default `jj log` output) by running the following in your repo:

```shell
jj config set --repo "revset-aliases.'immutable_heads()'" 'remote_branches(exact:"main") | remote_branches(exact:"gh-pages")'
```

### Summary

One-time setup:
Expand Down
3 changes: 2 additions & 1 deletion docs/revsets.md
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,8 @@ for a comprehensive list.
'trunk()' = 'your-branch@your-remote'
```

* `immutable_heads()`: Resolves to `trunk() | tags()` by default. See
* `immutable_heads()`: Resolves to `trunk() | tags() |
untracked_remote_branches()` by default. See
[here](config.md#set-of-immutable-commits) for details.

* `immutable()`: The set of commits that `jj` treats as immutable. This is
Expand Down

0 comments on commit ea3a574

Please sign in to comment.