Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
105 changes: 64 additions & 41 deletions cli/src/config/templates.toml
Original file line number Diff line number Diff line change
Expand Up @@ -142,19 +142,16 @@ 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(),
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",
)
)
Expand All @@ -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",
),
)
Expand Down Expand Up @@ -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",
),
)
Expand Down Expand Up @@ -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",
)
'''
Expand Down Expand Up @@ -299,10 +285,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",
)
Expand Down Expand Up @@ -357,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),
),
),
),
Expand All @@ -373,7 +357,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"
)
'''
Expand Down Expand Up @@ -403,6 +390,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",
Expand Down Expand Up @@ -495,6 +492,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)' = '''
Expand All @@ -507,14 +510,28 @@ 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),
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(),
Expand All @@ -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)
Expand All @@ -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(),
Expand Down
7 changes: 5 additions & 2 deletions cli/tests/test_log_command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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]
Expand Down
Loading