Skip to content

docs(config): document the machine-local default-branch override - #3947

Merged
max-sixty merged 2 commits into
mainfrom
docs/issue-3946-local-default-branch
Aug 28, 2026
Merged

max-sixty merged 2 commits into
mainfrom
docs/issue-3946-local-default-branch

Conversation

@worktrunk-bot

@worktrunk-bot worktrunk-bot commented Aug 28, 2026 •

Copy link
Copy Markdown
Collaborator

Problem

wt config state default-branch set writes worktrunk.default-branch to the repository's local git config, so an override lives in .git/config — never committed, never pushed, and shared across every linked worktree of the clone. #3946 reports that nothing says so: the detection list names the config key, but the docs never state that setting it is a supported override. That matters for anyone working in a repository they don't own (a client's, an upstream project's) whose remote HEAD names a branch other than the one they integrate against — the file-based config the docs point at is exactly what they can't add. There is no default-branch key in wt.toml or user config either, so the git config key is the only route.

Solution

Two additions, no behavior change:

  • src/cli/config.rs — a new "Overriding without a config file" section in wt config state default-branch's after_long_help, covering where the value is written, that it stays on one machine, that it applies to every linked worktree, that it's the only override there is, and that the branch has to be checked out locally or set and every subsequent wt list warn about it. The Detection section's existing drift sentence gains the "expected for a deliberate override, and inspection-only either way" qualifier rather than the new section restating it.
  • docs/src/content/docs/tips-patterns.md — a matching tip beside the existing "Reuse default-branch" section, which is where the reporter looked.

The generated mirrors under docs/, skills/, and plugins/ come from the sync test.

Testing

Verified against a scratch clone with the built binary: wt config state default-branch set integration writes [worktrunk] default-branch = integration, git config --show-scope reports local, and reading it back from a linked worktree returns integration. With origin/integration fetched but no local integration, set warns ▲ Branch integration does not exist locally and every wt list repeats ▲ Configured default branch integration does not exist locally with the clear hint; the summary line gains 1 ahead only once integration is checked out. The console example's output line is the command's real success message.

cargo test --test integration test_docs_are_in_sync (twice — regenerate, then clean), cargo insta test --accept --test integration -- test_help, and cargo fmt --check all pass.

Scratch-repo verification
$ wt config state default-branch set integration
✓ Set default branch to integration
$ git config --show-scope --get worktrunk.default-branch
local	integration
$ git worktree add -q ../wt-int integration && cd ../wt-int && wt config state default-branch
integration

Stale-override case, in a clone with only origin/integration:

$ wt config state default-branch set integration
▲ Branch integration does not exist locally
✓ Set default branch to integration
$ wt list
▲ Configured default branch integration does not exist locally
↳ To reset, run wt config state default-branch clear

Closes #3946 — automated triage

@worktrunk-bot worktrunk-bot added the automated-fix Automated CI fix label Aug 28, 2026

@worktrunk-bot worktrunk-bot left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Docs-only, and the mechanical claims check out against the code: set_config_value runs git config <key> <value> with no scope flag, so the write lands in the repo-local .git/config in the common git dir (shared by every linked worktree, never committed); remote_head() has exactly two callers, both in handle_state_show_{json,table}, so the drift report really is inspection-only; and ✓ Set default branch to integration is the literal success_message from handle_state_set.

One gap worth closing, plus two wording notes.

An override without a local branch is not left alone by ordinary commands. handle_state_set warns when refs/heads/<value> is missing, and wt list re-warns on every run — the warn_stale_default branch in commands/list/collect/mod.rs tests the configured default against local_branches() (a refs/heads/ scan) and emits Configured default branch <b> does not exist locally followed by a hint to run wt config state default-branch clear, i.e. to undo the deliberate override. needs_stale_check fires on plain wt list, not just --full. That's the scenario this section is written for: someone in a client's repo who has origin/integration fetched but never checked it out gets the nag every run. wt merge is fine, since require_target_branch goes through Branch::exists() (local or remote) — so the fix is one sentence telling the reader to check the branch out, not a caveat about breakage. Inline suggestions on both primaries.

wt.toml isn't an alternative route for this setting. There's no default-branch key in src/config/user/sections.rs or src/config/project.rs — the git config key is the only override. "needs no wt.toml" / "no wt.toml is needed" reads as relief from a file-based option that was never on the table; "this is the only way to override detection" is both accurate and more useful to someone deciding whether they've missed something.

wt config state default-branch's page now says the same thing three times. The intro already has "Use set to override, or clear then get to re-detect", and the Detection section closes with "wt config state flags the drift when the cached value differs from the remote's local HEAD; set adopts the new branch and clear re-detects". The new section's last paragraph restates both. The genuinely new material is the storage location and its machine/clone scope — the drift and clear sentences could go, or the Detection closer could, but keeping all three makes the page read as if they describe different things.

Not approving — self-authored, so GitHub rejects it either way.

Applying either suggestion means re-running cargo insta test --accept --test integration -- test_help and test_docs_are_in_sync, since src/cli/config.rs feeds the help snapshot and the four generated mirrors.

Comment thread src/cli/config.rs Resolved
Comment thread docs/src/content/docs/tips-patterns.md Resolved
…override

Address review feedback on #3947:

- an override whose branch has no local ref is not left alone: `set`
  warns and every `wt list` re-warns with a hint to clear it, then
  skips comparisons against the default branch. Both primaries now say
  to check the branch out first.
- `wt.toml` was never an alternative route, so "needs no wt.toml" is
  replaced by the accurate framing: the git config key is the only way
  to override detection.
- drop the duplicated drift/clear paragraph from the help page; the
  Detection section already covers it, now qualified with
  "expected for a deliberate override".
@max-sixty
max-sixty merged commit af04e80 into main Aug 28, 2026
42 checks passed
@max-sixty
max-sixty deleted the docs/issue-3946-local-default-branch branch August 28, 2026 15:29
max-sixty added a commit that referenced this pull request Aug 28, 2026
Shortens the default-branch override guidance added in #3947 while
keeping the clone-local scope, linked-worktree behavior, and
local-branch requirement.

> _This was written by Codex on behalf of max-sixty_
social4hyq pushed a commit to social4hyq/homebrew-core that referenced this pull request Sep 20, 2026
worktrunk 0.76.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

- **`wt switch --execute` takes a program, not a shell string**: `-x` names one program, with everything after `--` passed as literal argv. Worktrunk spawns it as a child rather than running it in your interactive shell, so shell functions and its `cd` no longer reach you. `-x sh -- -c '…'` recovers shell syntax, not functions. (Breaking: existing `-x` strings, plus `WORKTRUNK_DIRECTIVE_EXEC_FILE` and `WORKTRUNK_SHELL`.) ([#3977](max-sixty/worktrunk#3977), closes [#2860](max-sixty/worktrunk#2860), fixes [#3944](max-sixty/worktrunk#3944), thanks @omgreenfield for testing the migration path)

- **Worktrunk decides tracking for the branches it creates**: a new branch gets an upstream only when its name matches the remote branch it starts from, whatever `branch.autoSetupMerge` says: `--create release --base origin/release` tracks, `--create feature --base origin/release` does not. Under `autoSetupMerge = false` this previously exited 128 after creating the worktree. ([#3913](max-sixty/worktrunk#3913), [#3950](max-sixty/worktrunk#3950), fixes [#3937](max-sixty/worktrunk#3937), thanks @mjakl for reporting and diagnosing)

- **Retired config keys are no longer read**: `commit.generation.template-file` and `squash-template-file` are gone — put the file's contents in `template` or `squash-template`. There is no migration: the key stays, warns as unknown on every load, and the prompt reverts to the built-in default. Setting both `template` and `template-file` used to fail the load; it now loads `template`. `switch.picker.timeout-ms` likewise warns rather than being stripped. (Breaking.) ([#3949](max-sixty/worktrunk#3949))

- **Project aliases and hooks can use `wt switch --execute`**: their bodies previously refused it. Worktrunk now starts the program itself instead of handing shell text to your shell, and the command-approval gate remains the control on project-defined commands. ([#3977](max-sixty/worktrunk#3977))

- **Established automation and LLM customization interfaces are now stable**: `wt step eval`, `wt step for-each`, `wt step prune`, LLM branch summaries, `wt config state vars`, and `commit.generation.template-append` are no longer marked experimental. ([#3949](max-sixty/worktrunk#3949))

- **`wt step prune` stages removals concurrently again**: only the `git worktree remove` teardowns serialize, so dirty checks, fsmonitor shutdown, and the trash rename overlap. The `prune_e2e/live` benchmark median went from 377 ms to 222 ms. ([#3954](max-sixty/worktrunk#3954))

- **`wt config approvals add` reads as a review rather than a warning**: it opens with a cyan `Review 1 command for repo:` instead of a yellow `▲ … needs approval to execute`. The execution-time gate is unchanged. ([#3953](max-sixty/worktrunk#3953))

### Fixed

- **The `wt switch` picker survives a preview longer than 65,535 lines**: skim keeps the pane's line count in a `u16`, so a larger diff aborted `wt` with exit 101 seconds after it painted — on screen the picker looked like it closed by itself. Panes now cap at 60,000 lines and say so. ([#3959](max-sixty/worktrunk#3959), fixes [#3958](max-sixty/worktrunk#3958), thanks @sandertammesoo for reporting and diagnosing)

- **The nushell wrapper propagates exit codes without a POSIX shell**: it reported a failing `wt` by spawning `sh`, so on Windows every failing command printed a ``Command `sh` not found`` trace and exit 1 whatever the real code was. Nushell's wrapper is a static file, so rerun `wt config shell install` to pick this up. ([#3945](max-sixty/worktrunk#3945))

- **The picker no longer shows one detached worktree's diff for another**: previews were keyed by branch name, so every detached row shared the key `(detached)`. Rows now key by canonical identity, which also lets `wt remove feature ~/repo.feature` plan that worktree once instead of failing on the second. ([#3926](max-sixty/worktrunk#3926))

- **`wt switch pr:<n>` gives `pre-switch` hooks the real branch**: `branch` and `target` held the literal `pr:3933`, and `target_worktree_path` was unset even when that branch had a worktree. `pr_number` and `pr_url` are now set for same-repo PRs, not only forks. ([#3941](max-sixty/worktrunk#3941), fixes [#3934](max-sixty/worktrunk#3934), thanks @robsonpeixoto for reporting)

- **`wt config shell install` no longer replaces an rc file created while it was checking**: the missing-file path refuses to clobber and fails with a rerun hint. A dangling rc symlink is preserved and rejected rather than overwritten. ([#3929](max-sixty/worktrunk#3929))

- **`wt switch --create X --base pr:<n>` works when the PR branch has no local branch**: the fetch writes only the remote-tracking ref, and git won't expand a bare name to one, so the command failed with `No branch, tag, or commit named …`. The base is now named under its remote. ([#3951](max-sixty/worktrunk#3951))

- **`wt switch --create` streams `git worktree add` instead of stalling**: where a sandbox denied the timed wait's pipe or `sigaction`, the command waited out git's entire run and then reported `Failed to wait for command` for work that had already succeeded. ([#3881](max-sixty/worktrunk#3881))

- **Claude Code activity markers stay on the session's launch worktree**: the plugin's marker hooks pass `-C "$CLAUDE_PROJECT_DIR"`, so a `cd` mid-session no longer marks another repository. A session launched outside a repository gets no marker. ([#3956](max-sixty/worktrunk#3956))

### Documentation

- **`--execute` documents how to get a variable into a shell body**: each position is substituted verbatim, so a variable spliced into `sh -c` text is re-parsed by that shell and splits on spaces. The help now shows passing it as a separate argument and referencing it positionally. ([#3977](max-sixty/worktrunk#3977))

- **The clone-local default-branch override is documented**: `wt config state default-branch set` writes `worktrunk.default-branch` to the clone's local git config — machine-local, never committed, and shared by every linked worktree. `set` warns when the branch isn't checked out locally, and `wt list` skips its comparisons until it is. ([#3947](max-sixty/worktrunk#3947), [#3948](max-sixty/worktrunk#3948), fixes [#3946](max-sixty/worktrunk#3946), thanks @danielo515 for the request)

- **The docs site renders code with the CLI's own colors**: terminal examples reproduce each snapshot's exact ANSI roles, while command references and the homepage command comparison get clap and shell syntax color from paired light/dark themes. File excerpts gain a path tab, and code wraps instead of scrolling on mobile. ([#3936](max-sixty/worktrunk#3936), [#3938](max-sixty/worktrunk#3938), [#3939](max-sixty/worktrunk#3939), [#3942](max-sixty/worktrunk#3942))

- **The `pre-start` upstream example uses `--base`**: it showed `wt switch --create feature origin/feature`, which `wt switch` rejects. ([#3955](max-sixty/worktrunk#3955))

### Internal

- **Library API rework** (Breaking library API): `cargo-semver-checks` fails ten lints — `RemoteRefProvider` and its provider structs give way to `ForgeKind` dispatch, the `--execute` rework retires the fish and PowerShell `ShellEscapeMode` escapes and `WORKTRUNK_SHELL_ENV_VAR`, `BranchRef` swaps `full_ref`/`worktree_path` for `id`, and accessors including `Branch::unset_upstream` and `ProjectConfig::ci_platform` are gone. ([#3913](max-sixty/worktrunk#3913), [#3926](max-sixty/worktrunk#3926), [#3949](max-sixty/worktrunk#3949), [#3963](max-sixty/worktrunk#3963), [#3977](max-sixty/worktrunk#3977))

- **Hook pipelines and `wt list` collection lost two indirection layers**: the background pipeline carries `PreparedStep` directly, and 15 marker task types collapse into one exhaustive dispatch. The synthesized-`--force` submodule path keeps its dirty re-check and destructive command under one lock, so prune's narrower locking doesn't widen that window. ([#3964](max-sixty/worktrunk#3964), [#3954](max-sixty/worktrunk#3954))

## Install worktrunk 0.76.0

### Install prebuilt binaries via shell script

```sh
curl --proto '=https' --tlsv1.2 -LsSf https://github.com/max-sixty/worktrunk/releases/download/v0.76.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.76.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.76.0

|  File  | Platform | Checksum |
|--------|----------|----------|
| [worktrunk-aarch64-apple-darwin.tar.xz](https://github.com/max-sixty/worktrunk/releases/download/v0.76.0/worktrunk-aarch64-apple-darwin.tar.xz) | Apple Silicon macOS | [checksum](https://github.com/max-sixty/worktrunk/releases/download/v0.76.0/worktrunk-aarch64-apple-darwin.tar.xz.sha256) |
| [worktrunk-x86_64-ap

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

Labels

automated-fix Automated CI fix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Document that the default branch can be overwritten locally without any configuration file.

2 participants