From 0a8d8dad67c1d830025327b828724ed379453ba6 Mon Sep 17 00:00:00 2001 From: Yuya Nishihara Date: Mon, 30 Sep 2024 20:01:39 +0900 Subject: [PATCH] cli: make default log revset work without working-copy commit Spotted while adding an error propagation path from IdPrefixContext. --- cli/src/config-schema.json | 2 +- cli/src/config/revsets.toml | 2 +- cli/tests/test_commit_template.rs | 13 +++++++++++++ docs/config.md | 3 ++- 4 files changed, 17 insertions(+), 3 deletions(-) diff --git a/cli/src/config-schema.json b/cli/src/config-schema.json index 997d62c829..b3faa02d78 100644 --- a/cli/src/config-schema.json +++ b/cli/src/config-schema.json @@ -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", diff --git a/cli/src/config/revsets.toml b/cli/src/config/revsets.toml index 5a840a5dbf..b07b3cdfbf 100644 --- a/cli/src/config/revsets.toml +++ b/cli/src/config/revsets.toml @@ -3,7 +3,7 @@ [revsets] fix = "reachable(@, mutable())" -log = "@ | ancestors(immutable_heads().., 2) | trunk()" +log = "present(@) | ancestors(immutable_heads().., 2) | trunk()" [revset-aliases] 'trunk()' = ''' diff --git a/cli/tests/test_commit_template.rs b/cli/tests/test_commit_template.rs index 6bdf464598..d7e3688888 100644 --- a/cli/tests/test_commit_template.rs +++ b/cli/tests/test_commit_template.rs @@ -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(); diff --git a/docs/config.md b/docs/config.md index 1c1ae2aef6..34f636253d 100644 --- a/docs/config.md +++ b/docs/config.md @@ -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