Skip to content

Commit

Permalink
cli: make default log revset work without working-copy commit
Browse files Browse the repository at this point in the history
Spotted while adding an error propagation path from IdPrefixContext.
  • Loading branch information
yuja committed Oct 1, 2024
1 parent 1f5835c commit 0a8d8da
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 3 deletions.
2 changes: 1 addition & 1 deletion cli/src/config-schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,7 @@
"log": {
"type": "string",
"description": "Default set of revisions to show when no explicit revset is given for jj log and similar commands",
"default": "@ | ancestors(immutable_heads().., 2) | trunk()"
"default": "present(@) | ancestors(immutable_heads().., 2) | trunk()"
},
"short-prefixes": {
"type": "string",
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 @@ -3,7 +3,7 @@

[revsets]
fix = "reachable(@, mutable())"
log = "@ | ancestors(immutable_heads().., 2) | trunk()"
log = "present(@) | ancestors(immutable_heads().., 2) | trunk()"

[revset-aliases]
'trunk()' = '''
Expand Down
13 changes: 13 additions & 0 deletions cli/tests/test_commit_template.rs
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,19 @@ fn test_log_default() {
"#);
}

#[test]
fn test_log_default_without_working_copy() {
let test_env = TestEnvironment::default();
test_env.jj_cmd_ok(test_env.env_root(), &["git", "init", "repo"]);
let repo_path = test_env.env_root().join("repo");

test_env.jj_cmd_ok(&repo_path, &["workspace", "forget"]);
let stdout = test_env.jj_cmd_success(&repo_path, &["log"]);
insta::assert_snapshot!(stdout, @r#"
◆ zzzzzzzz root() 00000000
"#);
}

#[test]
fn test_log_builtin_templates() {
let test_env = TestEnvironment::default();
Expand Down
3 changes: 2 additions & 1 deletion docs/config.md
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,8 @@ You can configure the revisions `jj log` would show when neither `-r` nor any pa
revsets.log = "main@origin.."
```

The default value for `revsets.log` is `'@ | ancestors(immutable_heads().., 2) | trunk()'`.
The default value for `revsets.log` is
`'present(@) | ancestors(immutable_heads().., 2) | trunk()'`.

### Graph style

Expand Down

0 comments on commit 0a8d8da

Please sign in to comment.