worktrunk icon indicating copy to clipboard operation
worktrunk copied to clipboard

wt merge ignores project-config [merge] keys without the warning config show and switch both print

Open ee-prog opened this issue 2 months ago • 1 comments

wt v0.77.0, macOS arm64 (Homebrew).

merge.* in a project config is ignored, which is documented. The problem is which commands say so. wt config show warns, and so does wt switch:

▲ Project config has key merge which belongs in user config (will be ignored);
  to scope it to this repo, add it under [projects."<id>"] in user config

wt merge does not, and it is the command those keys govern. With ff = false and squash = false set in the project config, a plain wt merge fast-forwards, prints no warning, and exits 0:

$ wt -C ../repro.feat merge --no-remove
◎ Running pre-merge project:gate
GATE-RAN
✓ Merged to main (1 commit, 1 file, +1, -1)
$ git log --oneline --graph -3 main
* 2088781 a change
* 39aa2d9 init

No merge commit, though the config asked for one.

Repro

mkdir repro && cd repro && git init -b main .
mkdir -p .config
printf '[merge]\nsquash = false\nff = false\n' > .config/wt.toml
echo base > f && git add -A && git commit -m init
wt switch -c feat --no-cd
(cd ../repro.feat && echo change > f && git commit -am change)
wt -C ../repro.feat merge --no-remove
git log --oneline --graph -3 main   # linear: fast-forwarded, no warning
wt config show                       # here the warning appears

Why it bites

A repo cannot express its own merge policy in the file it shares with contributors, which is understandable, but the failure mode is silent divergence: a machine whose user config carries the [projects."..."] entry merges the way the project intends, and a fresh checkout of the same repo quietly does the opposite. We only found it by testing for it, and now carry explicit --no-ff --no-squash flags on every merge because of it.

Expected

wt merge emits the same warning the other commands already do when the project config sets keys it will ignore. That is enough; it makes the divergence visible at the point it happens.

ee-prog avatar Sep 16 '26 18:09 ee-prog

Good catch, and the diagnosis is slightly worse than the report: wt merge isn't a special case. ProjectConfig::load gates the "will be ignored" warning on being in the primary worktree, so no command warns from a linked worktree — wt list and wt switch are silent there too. wt switch warned in your repro because you ran it from repro, and wt merge didn't because you ran it from repro.feat. wt config show warns anywhere because it renders the same warnings through its own path, which has no such gate. In a bare-repo layout, where every worktree is linked, the warning never fires at all.

#4145 drops that gate, so the message lands on whatever command reads the config, from wherever it's run. On your repro:

$ wt -C ../repro.feat merge --no-remove
▲ Project config has key merge which belongs in user config (will be ignored); to scope it to this repo, add it under [projects."<id>"] in user config
◎ Merging 1 commit to main @ 1552839 …

The deprecation warning next to it keeps the gate — its message points at wt config update, which does need the primary worktree — but this one's fix (edit the tracked file, or move the key to user config) works from any worktree, which is why the original "only where it's actionable" reasoning doesn't carry over.

Your --no-ff --no-squash flags stay necessary either way; the PR only makes the divergence audible. If you want the policy pinned per invocation rather than per machine, wt --config-set 'merge.ff = false' overrides the setting above both config files, so a project alias or wrapper can carry it.

It still needs maintainer review before it lands.

worktrunk-bot avatar Sep 16 '26 19:09 worktrunk-bot