Skip to content

FR: a format_workspace(workspace) alias in format_short_commit_header, like the redacted header has #10085

Description

@TomerAberbach

Is your feature request related to a problem? Please describe.

Changing how jj log renders a workspace name (other@) requires copying all of format_short_commit_header, because the plain header inlines commit.working_copies():

https://github.com/jj-vcs/jj/blob/efe0cf178581/cli/src/config/templates.toml#L510-L523

  commit.working_copies(),

while the redacted header, since #9470, formats each workspace with an alias:

  commit.working_copies().map(|workspace| format_workspace_redacted(workspace)),

A colors rule cannot target one workspace, since the only label is working_copies. A template can:

jj git init t && cd t
jj workspace add ../t-other --name other
jj config set --repo colors.ws_other '{ fg = "#e06c75" }'
jj log --no-graph --revisions 'other@' --color=always \
  --template 'self.working_copies().map(|workspace| if(workspace.name() == "other", label("ws_other", workspace), workspace)) ++ "\n"' | cat -v
^[[38;2;224;108;117mother@^[[39m

but getting it into jj log means overriding format_short_commit_header(commit) with a copy of the default that swaps that one call, which pins the copy to one jj version and discards any other customization of the header.

Describe the solution you'd like

'format_workspace(workspace)' = 'workspace'

'format_short_commit_header(commit)' = '''
separate(" ",
  ...
  commit.working_copies().map(|workspace| format_workspace(workspace)),
  ...

Output is unchanged for anyone who keeps the default.

Describe alternatives you've considered

  • Copying the header, as above.
  • A per-workspace label, label("workspace_name " ++ workspace.name(), ...), so colors."working_copies other" works without a template. A name with a space would break the label syntax.

Additional context

jj 0.44.0 on macOS. main (efe0cf1) has the same header.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    polish🪒🐃Make existing features more convenient and more consistent

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions