From 91d837bb08edf4cde55ec7f431f951a4cfeccf2b Mon Sep 17 00:00:00 2001 From: Joseph Lou Date: Sun, 30 Aug 2026 21:56:15 -0400 Subject: [PATCH 1/3] template: Add some aliases for `log` template elements Also added more info for redacted tags since they are now fully supported. Fixes #10085. --- cli/src/config/templates.toml | 59 ++++++++++++++++++++++++----------- cli/tests/test_log_command.rs | 7 +++-- 2 files changed, 46 insertions(+), 20 deletions(-) diff --git a/cli/src/config/templates.toml b/cli/src/config/templates.toml index afdb50828cf..5b645881130 100644 --- a/cli/src/config/templates.toml +++ b/cli/src/config/templates.toml @@ -142,9 +142,9 @@ if(commit.root(), format_short_change_id_with_change_offset(commit), format_short_signature_oneline(commit.author()), format_timestamp(commit_timestamp(commit)), - commit.bookmarks(), - commit.tags(), - commit.working_copies(), + format_commit_bookmarks(commit), + format_commit_tags(commit), + format_commit_working_copies(commit), format_short_commit_id(commit.commit_id()), format_commit_labels(commit), if(config("ui.show-cryptographic-signatures").as_boolean(), @@ -299,10 +299,11 @@ builtin_workspace_list = ''' concat( name, ": ", - separate( - " ", + separate(" ", if(root, root.relative()), - format_commit_summary_with_refs(target, format_commit_ref_names(target.bookmarks())), + format_commit_summary_with_refs(target, + format_commit_ref_names(target.bookmarks()) + ), ), "\n", ) @@ -403,6 +404,16 @@ if(ref.remote(), ) ''' +'format_commit_ref_redacted(ref, type)' = ''' +concat( + type, "-", hash(ref.name()).substr(0, 4), + if(ref.remote(), + "@remote-" ++ hash(ref.remote()).substr(0, 4), + if(!ref.synced(), "*") + ) +) +''' + 'format_ref_targets(ref)' = ''' if(ref.conflict(), separate("\n", @@ -495,6 +506,12 @@ coalesce( 'format_change_offset(commit)' = 'surround(label("change_offset", "/"), "", commit.change_offset())' +'format_commit_bookmarks(commit)' = 'commit.bookmarks()' + +'format_commit_tags(commit)' = 'commit.tags()' + +'format_commit_working_copies(commit)' = 'commit.working_copies()' + # We have "hidden" override "divergent", since a hidden revision does not cause # divergence and is not affected by divergence. 'format_commit_labels(commit)' = ''' @@ -512,9 +529,9 @@ separate(" ", format_short_change_id_with_change_offset(commit), format_short_signature(commit.author()), format_timestamp(commit_timestamp(commit)), - commit.bookmarks(), - commit.tags(), - commit.working_copies(), + format_commit_bookmarks(commit), + format_commit_tags(commit), + format_commit_working_copies(commit), format_short_commit_id(commit.commit_id()), format_commit_labels(commit), if(config("ui.show-cryptographic-signatures").as_boolean(), @@ -523,6 +540,18 @@ separate(" ", ) ''' +'format_commit_bookmarks_redacted(commit)' = ''' +commit.bookmarks().map(|b| format_commit_ref_redacted(b, "bookmark")) +''' + +'format_commit_tags_redacted(commit)' = ''' +commit.tags().map(|tag| format_commit_ref_redacted(tag, "tag")) +''' + +'format_commit_working_copies_redacted(commit)' = ''' +commit.working_copies().map(|workspace| format_workspace_redacted(workspace)) +''' + # TODO: Possibly add some kind of repo-unique salt to the hash methods, if it # makes users feel more secure (right now, `main` will always be `branch-c8c7a` # for every repo) @@ -531,15 +560,9 @@ separate(" ", format_short_change_id_with_change_offset(commit), label("author", format_user_redacted(commit.author())), format_timestamp(commit_timestamp(commit)), - commit.bookmarks().map(|bookmark| concat( - "bookmark-", hash(bookmark.name()).substr(0, 4), - if(bookmark.remote(), - "@remote-" ++ hash(bookmark.remote()).substr(0, 4), - if(!bookmark.synced(), "*") - ) - )), - commit.tags().map(|tag| concat("tag-", hash(tag.name()).substr(0, 4))), - commit.working_copies().map(|workspace| format_workspace_redacted(workspace)), + format_commit_bookmarks_redacted(commit), + format_commit_tags_redacted(commit), + format_commit_working_copies_redacted(commit), format_short_commit_id(commit.commit_id()), format_commit_labels(commit), if(config("ui.show-cryptographic-signatures").as_boolean(), diff --git a/cli/tests/test_log_command.rs b/cli/tests/test_log_command.rs index 8a7708e8ec8..d850d748a4a 100644 --- a/cli/tests/test_log_command.rs +++ b/cli/tests/test_log_command.rs @@ -1867,6 +1867,9 @@ fn test_log_anonymize() { origin_dir .run_jj(["bookmark", "create", "-r@", "b1", "b2", "b3"]) .success(); + origin_dir + .run_jj(["tag", "set", "-r@", "tag1", "tag2"]) + .success(); origin_dir.run_jj(["git", "export"]).success(); test_env @@ -1879,9 +1882,9 @@ fn test_log_anonymize() { let output = work_dir.run_jj(["log", "-r::", "-Tbuiltin_log_redacted"]); insta::assert_snapshot!(output, @" - @ yqosqzyt user-78cd 2001-02-03 08:05:13 bookmark-dc8b* de3c47af + @ vruxwmqv user-78cd 2001-02-03 08:05:14 bookmark-dc8b* e1ae80a8 │ (empty) (redacted) - ◆ qpvuntsm user-78cd 2001-02-03 08:05:08 bookmark-dc8b@remote-86e9 bookmark-56f1 bookmark-ff9e@remote-86e9 37b69cda + ◆ qpvuntsm user-78cd 2001-02-03 08:05:08 bookmark-dc8b@remote-86e9 bookmark-56f1 bookmark-ff9e@remote-86e9 tag-b503 tag-fe97 37b69cda │ (empty) (redacted) ◆ zzzzzzzz root() 00000000 [EOF] From 9edf5f9f605a422b98733ba31d95fd2d406e00b9 Mon Sep 17 00:00:00 2001 From: Joseph Lou Date: Sun, 30 Aug 2026 21:56:15 -0400 Subject: [PATCH 2/3] template: Show local and remote refs separately for root commit It's strange for bookmarks or tags to be on the root commit (maybe from a `jj squash`), and they couldn't be pushed to a remote anyway (the root commit is virtual), so call it out by listing out all commit refs. --- cli/src/config/templates.toml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/cli/src/config/templates.toml b/cli/src/config/templates.toml index 5b645881130..6e56c1226cb 100644 --- a/cli/src/config/templates.toml +++ b/cli/src/config/templates.toml @@ -374,7 +374,10 @@ label("immutable", format_short_change_id(root.change_id()), label("root", "root()"), format_short_commit_id(root.commit_id()), - root.bookmarks(), + root.local_bookmarks(), + root.remote_bookmarks(), + root.local_tags(), + root.remote_tags(), ) ++ "\n" ) ''' From b3997e8481f37aa5c2f4aaa1e88cf607f67b52a2 Mon Sep 17 00:00:00 2001 From: Joseph Lou Date: Sun, 30 Aug 2026 21:56:15 -0400 Subject: [PATCH 3/3] template: Add alias function for commit description summary --- cli/src/config/templates.toml | 41 ++++++++++++++++------------------- 1 file changed, 19 insertions(+), 22 deletions(-) diff --git a/cli/src/config/templates.toml b/cli/src/config/templates.toml index 6e56c1226cb..58025f563d6 100644 --- a/cli/src/config/templates.toml +++ b/cli/src/config/templates.toml @@ -151,10 +151,7 @@ if(commit.root(), format_short_cryptographic_signature(commit.signature()) ), if(commit.empty(), empty_commit_marker), - if(commit.description(), - commit.description().first_line(), - label(if(commit.empty(), "empty"), description_placeholder), - ), + format_commit_description_summary(commit), ) ++ "\n", ) ) @@ -174,10 +171,7 @@ if(commit.root(), format_short_commit_header(commit) ++ "\n", separate(" ", if(commit.empty(), empty_commit_marker), - if(commit.description(), - commit.description().first_line(), - label(if(commit.empty(), "empty"), description_placeholder), - ), + format_commit_description_summary(commit), ) ++ "\n", ), ) @@ -221,10 +215,7 @@ if(commit.root(), format_short_commit_header(commit) ++ "\n", separate(" ", if(commit.empty(), empty_commit_marker), - if(commit.description(), - commit.description().trim_end(), - label(if(commit.empty(), "empty"), description_placeholder), - ), + format_commit_description_full(commit), ) ++ "\n", ), ) @@ -252,12 +243,7 @@ concat( ) ), "\n", - indent(" ", - if(commit.description(), - commit.description().trim_end(), - label(if(commit.empty(), "empty"), description_placeholder) - ) ++ "\n" - ), + indent(" ", format_commit_description_full(commit) ++ "\n"), "\n", ) ''' @@ -358,10 +344,7 @@ label(if(commit.current_working_copy(), "working_copy"), separate(" ", format_commit_labels(commit), if(commit.empty(), empty_commit_marker), - if(commit.description(), - commit.description().first_line(), - label(if(commit.empty(), "empty"), description_placeholder), - ), + format_commit_description_summary(commit), ), ), ), @@ -527,6 +510,20 @@ separate(" ", ) ''' +'format_commit_description_summary(commit)' = ''' +if(commit.description(), + commit.description().first_line(), + label(if(commit.empty(), "empty"), description_placeholder), +) +''' + +'format_commit_description_full(commit)' = ''' +if(commit.description(), + commit.description().trim_end(), + label(if(commit.empty(), "empty"), description_placeholder), +) +''' + 'format_short_commit_header(commit)' = ''' separate(" ", format_short_change_id_with_change_offset(commit),