Skip to content

Feature request: Add the ability to show git branch config variables in the list command. #3258

Closed

Description

@cazador481

I would like the work tree list command to show various variables that are stored in the git branch config that is associated with the work tree. For example, I store my Jira tickets and state in the git configuration, including a high-level description. It would be nice to be able to get into the list.

Activity

  1. worktrunk-bot commented on Jun 26, 2026

    @worktrunk-bot
    Collaborator

    Thanks for the suggestion! Most of this already exists today via custom columns (experimental) plus per-branch variables, though with one caveat on where the data lives.

    wt list can render arbitrary per-branch values in a column. You define the column in user config and set the values per branch:

    [list.custom-columns.Ticket]
    template = "{{ vars.ticket }}"   # the rendered result is the cell text
    width = 20                       # optional, default 40
    priority = 9                     # optional drop order when the terminal narrows
    
    [list.custom-columns.Note]
    template = "{{ vars.note }}"
    wt config state vars set ticket PROJ-123
    wt config state vars set note "High-level description of this branch"

    A column that's empty for every row is dropped automatically, and wt list --format json includes the rendered values under columns. This is the exact use case the feature was built for — tracking what each of many branches is for (Jira ID, state, a free-form description). Docs: custom columns and wt config state vars.

    The caveat: these vars are stored under worktrunk's own git-config namespace (worktrunk.state.<branch>.vars.<key>), and the {{ vars.* }} template only reads from that namespace. If your Jira/state data is already in git config under your own keys (e.g. branch.<name>.jira), wt list won't pick those up today — you'd either re-store them via wt config state vars set, or this becomes the genuine gap: a way to surface arbitrary git config keys (not just worktrunk's namespace) in a column.

    So the question for prioritization: does setting your values with wt config state vars set cover what you need, or is reading your existing arbitrary git config keys an important part of the ask? That distinction decides whether this is already solved or a real feature gap. A maintainer can weigh in on the latter.

    Sources
  2. cazador481 commented on Jun 26, 2026

    @cazador481
    Author

    My need is to pull the information from the git branch config. I sometimes use the same worktree when working in multiple branches over time.

  3. worktrunk-bot commented on Jun 26, 2026

    @worktrunk-bot
    Collaborator

    Got it — that confirms it's the real gap, not the already-solved part. You want wt list to read keys you already store yourself under branch.<name>.* in git config (e.g. branch.feature-x.jira), without re-storing them through wt config state vars set. The "same worktree across branches over time" detail is the clincher: keying on the branch's own config is exactly right for that, since the data follows the branch rather than the worktree.

    For the record, there's no clean workaround today — custom-column templates only resolve {{ vars.* }}, which reads solely from worktrunk's worktrunk.state.<branch>.vars.* namespace, and an alias can't widen that. So this is a native feature, not an alias.

    Roughly what an implementation would add: a second template namespace in the custom-column context that exposes the branch's own git config, e.g.

    [list.custom-columns.Ticket]
    template = "{{ branch_config.jira }}"   # reads branch.<name>.jira

    The open design questions for a maintainer (this part isn't mine to decide):

    • Scope of exposed keys — only branch.<name>.*, or arbitrary git config? Branch-scoped is the safer, more obviously-useful default and matches your use case.
    • Namespace name and key access — branch_config.jira vs. something explicit about the branch. prefix, and how to handle keys with dots/dashes in minijinja.
    • Cost — wt list renders many rows; this should fold into one bulk git config --get-regexp ^branch\. read (like all_vars_entries already does for vars), not a per-row call.

    I'll leave the prioritization and the design calls above to a maintainer. Thanks for clarifying — this is a clean, self-contained ask.

  4. max-sixty commented on Jun 26, 2026

    @max-sixty
    Owner

    yes, very reasonable suggestion, thanks @cazador481

    how are these stored atm in your config? i.e. what would you run to extract them for a specific branch?

  5. cazador481 commented on Jun 26, 2026

    @cazador481
    Author

    Here is an example from my current .git/config file:

    [branch "HWINFCI-2810"]
    	description = "[INTERNAL] HWINFCI-2810: Instrument libraries to send telemetry, and initializes telemetry for CLI apps\n\n# Description\nI added instrumentation to a number of python libraries to send usage\ninformation to the default hwinfci otel connector.\n\nI also added the otel connector initialization to the python cli applications.\n\nNote: Currently the default connector is None. See hwinfci-otel on how to setup a connector via env variables.\n\n"
    	shelf = 64645277
    	nvciShelf = 64694152
    	review = 202074
    	jira = HWINFCI-2810

    What I do today to extract my data is call
    git config branch..
    Example:

    > git config branch.HWINFCI-8758.jira
    HWINFCI-8758

    For the description, my code today uses just the first line. As that line contains a 1 sentence summary. (Ideally, I could say just show me everything from the : onwards. But that is asking alot ) To set the branch description I usually use git branch --edit-description

    ❯ git config branch.HWINFCI-8758.description | head -n 1
    [BUG FIX] HWINFCI-9151: Update trace context header test for OpenTelemetry trace flags
  6. max-sixty commented on Jun 26, 2026

    @max-sixty
    Owner

    @worktrunk-bot is there a git-native way of assigning configs to branches? or is the example above just a convention?

  7. worktrunk-bot commented on Jun 26, 2026

    @worktrunk-bot
    Collaborator

    Both, depending on the key. Git natively defines a small fixed set of branch.<name>.* keys and assigns them meaning; everything else in that namespace (jira, shelf, review, nvciShelf) is pure convention — git stores it but does nothing with it.

    The git-native ones (from git help config, verified on git 2.54.0):

    • branch.<name>.remote, branch.<name>.pushRemote, branch.<name>.merge, branch.<name>.mergeOptions, branch.<name>.rebase — upstream/push tracking, normally written by git branch --set-upstream-to / git push -u.
    • branch.<name>.description — the one that matters here. It's git-native, edited with git branch --edit-description, and git itself consumes it (auto-added to the format-patch cover letter and request-pull summary). That's exactly the key @cazador481 sets via git branch --edit-description.

    There is no git-native "assign a config to a branch" command beyond the generic git config branch.<name>.<key> <value>. Custom keys like jira are set that way and only have meaning to the tooling that reads them — there's no schema and git never validates or uses them.

    What this means for the feature: a branch.<name>.* namespace is the right thing to expose, since it's where both git-native (description) and convention keys (jira) already live, and it's stable across git versions. One subtlety worth designing around — description is multi-line by git's own convention (git branch --edit-description opens an editor), and @cazador481's use case wants just the first line. So a column template reading description should probably expose the first line (or offer both), rather than rendering an embedded-newline blob into a table cell.

    Verification

    git 2.54.0, git help config:

    branch.<name>.description
        Branch description, can be edited with git branch
        --edit-description. Branch description is automatically added to
        the format-patch cover letter or request-pull summary.
    

    Confirmed a custom key round-trips with no git-native meaning:

    $ git config branch.main.jira PROJ-123
    $ git config branch.main.jira
    PROJ-123
    $ git config --get-regexp '^branch\.main\.'
    branch.main.jira PROJ-123
    branch.main.description line1\nline2
    

    Native branch.<name>.* keys per the docs: remote, pushRemote, merge, mergeOptions, rebase, description. The rest are convention only.

  8. max-sixty commented on Jun 27, 2026

    @max-sixty
    Owner

    did we ever land the custom command that could be run for a custom column?

  9. worktrunk-bot commented on Jun 27, 2026

    @worktrunk-bot
    Collaborator

    No — what landed in #3073 is template-only. A [list.custom-columns.<Header>] cell is a minijinja template rendered over in-memory data (branch, worktree_path, worktree_name, vars.*); there's no field that shells out per cell. It was deliberately built that way — wt list renders many rows on the time-to-skeleton path, so custom_columns.rs is explicit that expansion runs "zero subprocesses per cell."

    So a command-backed column is still unbuilt. There's no ListColumnConfig field for it (src/config/user/sections.rs L145-157, only template/width/priority), and I found no open issue/PR proposing one.

    Worth noting it doesn't actually unblock @cazador481's ask. Reading branch.<name>.jira / branch.<name>.description is a local config read, so the right fix there is a branch_config.* template namespace folded into the one bulk git config --get-regexp ^branch\. read (like all_vars_entries already does for vars) — not a per-row subprocess. A general "run a command per cell" feature is a separate, heavier thing: it reintroduces the O(rows) subprocess cost the design avoided, and runs project-config-derived commands, which would have to clear the approval gate. If you want, I can spin up a small design proposal in design/ for the branch_config.* namespace (the cheap, self-contained win) and note command-backed columns as a deliberately-deferred alternative.

  10. max-sixty commented on Jun 29, 2026

    @max-sixty
    Owner

    Shipped in #3319 (on main now, in the next release).

    wt list custom columns can now read a branch's own git config under branch.<name>.* via a new {{ git.branch.* }} template namespace — no wt config state vars set round-trip. It maps straight to git config branch.<name>.<key>, so your existing keys work as-is:

    [list.custom-columns.Jira]
    template = "{{ git.branch.jira }}"
    
    [list.custom-columns.Summary]
    template = "{{ git.branch.description | lines | first }}"

    That covers your workflow directly: {{ git.branch.jira }} reads branch.<name>.jira, and {{ git.branch.description | lines | first }} is the first line of the git-native description — the same result as your git config branch.<name>.description | head -n 1. One gotcha: git lowercases config variable names, so branch.<name>.nvciShelf reads as {{ git.branch.nvcishelf }}.

    A column that's empty on every row is dropped automatically, and wt list --format json includes the rendered values under columns. Docs: https://worktrunk.dev/config/#custom-columns

    Thanks for the clear request, @cazador481.

    This was written by Claude Code on behalf of max

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions