Skip to content

feat(list): add git.branch.* template namespace for custom columns - #3319

Merged
max-sixty merged 1 commit into
mainfrom
branch-config-var
Jun 29, 2026
Merged

max-sixty merged 1 commit into
mainfrom
branch-config-var

Conversation

@max-sixty

Copy link
Copy Markdown
Owner

Adds a {{ git.branch.* }} template namespace for wt list custom columns, parallel to {{ vars.* }}. It surfaces a branch's own git config under branch.<name>.* — both convention keys you set yourself (branch.<name>.jira) and the git-native branch.<name>.description — without re-storing the values through wt config state vars set. This is the gap left open in #3258: vars.* only reads worktrunk's worktrunk.state.<branch>.vars.* namespace, so keys a user already keeps in git config were invisible to the list.

Before / after

With branch.feature.jira and branch.feature.description already in .git/config:

[list.custom-columns.Jira]
template = "{{ git.branch.jira }}"
[list.custom-columns.Summary]
template = "{{ git.branch.description | lines | first }}"
Branch     …  Jira          Summary
feature    …  HWINFCI-2810  Add telemetry instrumentation
main       …                                                 ← no branch.main.*, empty cells

Previously the only way to populate these columns was to re-enter the data via wt config state vars set; now the branch's own config is read directly.

Design

  • A new git top-level namespace (rather than a flat branch_config) so it can grow other git-derived per-branch fields later (git.upstream, git.remote, …) without claiming a new top-level name each time. Today it holds git.branch.*.
  • git.branch.<key> maps 1:1 to git config branch.<name>.<key>. Note git lowercases config variable names, so branch.<name>.nvciShelf reads as {{ git.branch.nvcishelf }}; the git-native description is multi-line, so | lines | first gives the summary line.
  • Data comes from the existing in-memory bulk config snapshot — one read, zero subprocesses per cell, on the same skeleton-first path as vars. The reader shares a subsection_map_from_snapshot(parse) helper with the existing all_vars_from_snapshot.
  • Parsing splits branch.<name>.<key> with rsplit_once('.'), which is correct because git variable names can't contain dots: dotted/slashed branch names (feature.foo, feature/bar) keep their full subsection, and git's section-level keys (branch.sort, branch.autoSetupMerge) flatten to two segments and are skipped.
  • Scoped to list custom columns only — no leakage into hook/alias/pipeline template contexts.

Testing

Unit tests for the parser/reader (dotted + slashed branch names, variable-name lowercasing, branch.sort skip) and for rendering (including description | lines | first); a JSON integration test exercises the full wt list path end-to-end. Verified manually against a scratch repo. Full pre-merge gate green (4297 tests, clippy, fmt, rustdoc, docs-in-sync).

Closes #3258. Thanks to @cazador481 for the request.

This was written by Claude Code on behalf of max

Custom columns can read a branch's own git config under branch.<name>.*
via {{ git.branch.* }}, parallel to {{ vars.* }} — e.g.
{{ git.branch.jira }} or {{ git.branch.description | lines | first }} —
without re-storing the values through `wt config state vars set`.

A new top-level `git` namespace keeps room to grow (git.upstream,
git.remote, …) rather than a flat single-purpose name. Data comes from
the in-memory bulk config snapshot (one read, zero subprocess per cell)
through a shared subsection_map_from_snapshot helper that also backs the
existing vars reader. Parsing splits branch.<name>.<key> with
rsplit_once, so dotted/slashed branch names keep their subsection and
git's section-level keys (branch.sort, …) are skipped.

Closes #3258

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

@worktrunk-bot worktrunk-bot left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed the implementation independently — it reads cleanly and I didn't find anything actionable. Nice that subsection_map_from_snapshot factors out the shared parse-and-collect loop instead of copying all_vars_from_snapshot, and parse_branch_config_key's rsplit_once('.') correctly keeps dotted/slashed branch subsections intact while dropping git's section-level keys like branch.sort. No data-loss surface, and the parser/reader/render paths are all covered by tests.

One CI note so the red isn't mistaken for a real signal: the code-coverage job failed at the Install shells (zsh, fish) step (awalsh128/cache-apt-pkgs-action, exit code 3) — a transient apt-package flake, not the change. The Generate coverage report and Upload to codecov.io steps were skipped as a result, so codecov/patch won't post on this commit. A rerun should clear it.

@max-sixty
max-sixty merged commit 4388def into main Jun 29, 2026
46 of 48 checks passed
@max-sixty
max-sixty deleted the branch-config-var branch June 29, 2026 18:19
social4hyq pushed a commit to social4hyq/homebrew-core that referenced this pull request Sep 20, 2026
worktrunk 0.64.0

Created-by: HarmonybrewBot
Commit-by: HarmonybrewBot
Merged-by: HarmonybrewBot
Description: Created by `brew bump`

---

Created with `brew bump-formula-pr`.<details>
  <summary>release notes</summary>
  <pre>## Release Notes

### Improved

- **`{{ git.branch.* }}` template namespace for custom columns**: `wt list` custom columns can now read a branch's own git config via `{{ git.branch.<key> }}` — both convention keys you set yourself (`branch.<name>.jira`) and the git-native `branch.<name>.description` — without re-storing the values through `wt config state vars set`. It complements `{{ vars.* }}`, which reads only worktrunk's own state namespace. ([#3319](max-sixty/worktrunk#3319), thanks @cazador481 for the request)

- **Faster warm-cache `wt list` re-runs**: A repeat `wt list` (with `.git/wt/cache/` already populated) is ~36% faster, by removing redundant per-row git subprocesses — priming the commit→tree cache from the `%ct` batch already issued, persisting merge-base results to a content-addressed on-disk cache, and seeding worktree roots and git-dirs from the single `git worktree list` instead of re-forking `git rev-parse` per worktree. ([#3334](max-sixty/worktrunk#3334))

### Fixed

- **Refs that look like flags can't inject git options**: `wt`'s `git diff` previews and diffstats (picker diff previews, `show_diffstat`, push diffstat) now fence user-controlled refs behind `--end-of-options`, and branch removal (`git branch -D`) passes them after `--`, so a branch literally named like a flag (`-x`, `--foo`) reaches git as a positional ref instead of being misparsed as an option. ([#3317](max-sixty/worktrunk#3317))

- **Statusline renders untruncated when `COLUMNS=0`**: `wt list statusline` treated `COLUMNS=0` as a zero-width budget and dropped every segment, rendering an empty line. A zero or unparsable `COLUMNS` is now treated as no detectable width, so the line renders everything untruncated — as the statusline sizing already documented for a missing width. ([#3318](max-sixty/worktrunk#3318))

- **Watchdog "still waiting" line uses the hint symbol**: The transient `Waiting for the commit message (Ns)` line shown during a slow `wt step commit` LLM call now uses the hint prefix (`↳`) instead of the info symbol (`○`), matching the convention for fully-dim status lines. ([#3330](max-sixty/worktrunk#3330))

## Install worktrunk 0.64.0

### Install prebuilt binaries via shell script

```sh
curl --proto '=https' --tlsv1.2 -LsSf https://github.com/max-sixty/worktrunk/releases/download/v0.64.0/worktrunk-installer.sh | sh && wt config shell install
```

### Install prebuilt binaries via powershell script

```sh
powershell -ExecutionPolicy Bypass -c "irm https://github.com/max-sixty/worktrunk/releases/download/v0.64.0/worktrunk-installer.ps1 | iex"; git-wt config shell install
```

### Install prebuilt binaries via Homebrew

```sh
brew install worktrunk && wt config shell install
```

## Download worktrunk 0.64.0

|  File  | Platform | Checksum |
|--------|----------|----------|
| [worktrunk-aarch64-apple-darwin.tar.xz](https://github.com/max-sixty/worktrunk/releases/download/v0.64.0/worktrunk-aarch64-apple-darwin.tar.xz) | Apple Silicon macOS | [checksum](https://github.com/max-sixty/worktrunk/releases/download/v0.64.0/worktrunk-aarch64-apple-darwin.tar.xz.sha256) |
| [worktrunk-x86_64-apple-darwin.tar.xz](https://github.com/max-sixty/worktrunk/releases/download/v0.64.0/worktrunk-x86_64-apple-darwin.tar.xz) | Intel macOS | [checksum](https://github.com/max-sixty/worktrunk/releases/download/v0.64.0/worktrunk-x86_64-apple-darwin.tar.xz.sha256) |
| [worktrunk-x86_64-pc-windows-msvc.zip](https://github.com/max-sixty/worktrunk/releases/download/v0.64.0/worktrunk-x86_64-pc-windows-msvc.zip) | x64 Windows | [checksum](https://github.com/max-sixty/worktrunk/releases/download/v0.64.0/worktrunk-x86_64-pc-windows-msvc.zip.sha256) |
| [worktrunk-aarch64-unknown-linux-musl.tar.xz](https://github.com/max-sixty/worktrunk/releases/download/v0.64.0/worktrunk-aarch64-unknown-linux-musl.tar.xz) | ARM64 MUSL Linux | [checksum](https://github.com/max-sixty/worktrunk/releases/download/v0.64.0/worktrunk-aarch64-unknown-linux-musl.tar.xz.sha256) |
| [worktrunk-x86_64-unknown-linux-musl.tar.xz](https://github.com/max-sixty/worktrunk/releases/download/v0.64.0/worktrunk-x86_64-unknown-linux-musl.tar.xz) | x64 MUSL Linux | [checksum](https://github.com/max-sixty/worktrunk/releases/download/v0.64.0/worktrunk-x86_64-unknown-linux-musl.tar.xz.sha256) |



### Install via Cargo

```sh
cargo install worktrunk && wt config shell install
```

### Install via Winget (Windows)

```sh
winget install max-sixty.worktrunk && git-wt config shell install
```

### Install via AUR (Arch Linux)

```sh
paru worktrunk-bin && wt config shell install
```
</pre>
  <p>View the full release notes at <a href="https://github.com/max-sixty/worktrunk/releases/tag/v0.64.0">https://github.com/max-sixty/worktrunk/releases/tag/v0.64.0</a>.</p>
</details>
<hr>

See merge request: Harmonybrew/homebrew-core!13223
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

2 participants