Skip to content

fix(git): scrub inherited GIT_DIR on worktree-local plumbing - #4082

Merged
max-sixty merged 5 commits into
max-sixty:mainfrom
Duang777:fix/issue-4081-git-wt-merge-false-conflict
Sep 14, 2026
Merged

max-sixty merged 5 commits into
max-sixty:mainfrom
Duang777:fix/issue-4081-git-wt-merge-false-conflict

Conversation

@Duang777

@Duang777 Duang777 commented Sep 13, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Review note

ensure_clean / is_dirty route through WorkingTree::run_command. Under an inherited GIT_DIR the gate previously read the invoking index while standing in the target worktree — a silent data-loss path for wt remove, not merely a wrong-tree answer. Regression: test_remove_refuses_dirty_target_when_git_dir_names_invoking_worktree.

Test plan

  • cargo test --test integration git_dir_names
  • Changelog leads with wt merge / wt remove command names (not git wt)
  • CLAUDE.md splits user-command relocation from worktree-local plumbing

A !wt alias from a linked worktree pins GIT_DIR to that worktree's
admin dir. WorkingTree::run_command forwarded it, so merge's target
conflict check compared the feature index to the main worktree and
refused a clean merge.

Co-authored-by: Cursor <cursoragent@cursor.com>
@worktrunk-bot

Copy link
Copy Markdown
Collaborator

Evidence for the review note about ensure_clean / is_dirty, from triaging #4081: that surface isn't only answering about the wrong worktree today — it loses data. Under an inherited GIT_DIR, ensure_clean compares the target's working tree against the invoking worktree's index, so when the two agree on a path a genuinely dirty worktree reads as clean and wt remove deletes it, with no --force and no warning. I reproduced it on main (28399c2) and confirmed this branch (fb80067) refuses the removal instead; the script and both transcripts are in my comment on #4081.

That makes the gate change a correction of a CLAUDE.md → Data Safety violation rather than a behavior change to weigh, which is the part I couldn't establish during the #4075 rounds. I also checked the fix doesn't just disable the gate: a target that is genuinely dirty on a path in the push range still blocks wt merge, and a genuinely dirty worktree still blocks wt remove.

Not a review verdict — the merge call is still @max-sixty's.

@max-sixty max-sixty left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

please review this much more thoroughly

Comment thread CHANGELOG.md Resolved

@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.

Holding the verdict for @max-sixty rather than approving. This diff changes what wt remove's deletion gate observes: ensure_clean → dirty_files → WorkingTree::run_command_output in src/git/repository/working_tree.rs is that gate, and the scrub added there decides whether a worktree holding uncommitted work gets deleted. The direction is right — the gate now reads the worktree being removed instead of the invoking one, and a genuinely dirty target still blocks — but a change to the deletion surface isn't mine to approve.

Two gaps worth closing whichever way that call goes.

The changelog entry covers only the merge symptom. The same scrub also closes a silent-data-loss path in wt remove (evidence) — the more severe of the two fixes, and the one a user scanning ### Fixed would most want to find. Suggested entry inline.

Nothing pins the removal gate. test_merge_syncs_target_when_git_dir_names_the_source asserts the merge succeeds, so it pins the conflict gate; no test sets GIT_DIR and exercises wt remove at all. That leaves the data-safety behavior resting on a test whose assertion is about merge output — it would stay green if ensure_clean / dirty_files were later routed through an unscrubbed path (a Repository-level status call, a new helper) while merge kept working. CLAUDE.md → Data Safety ("Prefer failure over silent loss") makes this the behavior most worth its own regression test: set GIT_DIR to the invoking worktree's private gitdir, leave the target dirty on a path the invoking index agrees about, and assert the removal is refused and the file survives.

Comment thread CHANGELOG.md Resolved
Comment thread CLAUDE.md Resolved
@worktrunk-bot

Copy link
Copy Markdown
Collaborator

One correction to the premise this PR is described against, since it affects how narrow the fix looks: I'd reported #4081 as a git wt bug, and that was wrong. Worktrunk's git wt is the git-wt binary dispatched as a git subcommand, and git exports no GIT_DIR to an external subcommand — that path merges cleanly on main (verified, git 2.55.0). The trigger is an inherited GIT_DIR, which a !wt alias is only one source of; git also hands one to the hooks it spawns, so a plain user post-commit hook calling wt merge from a linked worktree hits the same false conflict with no alias configured. Details and the case table are in the rewritten #4081.

The diff here is unaffected — the scrub covers the inherited variable regardless of what set it — so this is about the title and body wording reading narrower than the failure, not about the change itself.

Lead with wt command names in the changelog, add the wt remove data-safety
half, split worktree-local plumbing from user-command relocation in
CLAUDE.md, and pin the dirty gate with a GIT_DIR regression test.

Co-authored-by: Cursor <cursoragent@cursor.com>
@Duang777 Duang777 changed the title fix(git): scrub GIT_DIR so git wt merge sees the target worktree fix(git): scrub inherited GIT_DIR on worktree-local plumbing Sep 13, 2026
@Duang777

Copy link
Copy Markdown
Contributor Author

Addressed the review in 24a83d4:

CI re-running. Still holding for @max-sixty on the deletion-gate surface.

@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.

Two follow-ups on 24a83d4, both inline.

The new wt remove regression asserts only that the command failed, so it stays green whenever the removal errors for any reason at all — including a future change that never reaches the dirty gate under an inherited GIT_DIR, which is exactly the silent-deletion path the test is there to pin. Asserting the gate's own message closes that.

The CLAUDE.md classification now reads as though both worktree-local sites remove GIT_INDEX_FILE. TempIndex::command sets it, and since env-removes run last — the ordering the same sentence documents — an implementer who brings that site in line with the doc would drop the temp index and point register_untracked's git add --intent-to-add . at the user's real index.

The verdict still sits with @max-sixty: this diff decides what wt remove's deletion gate observes (ensure_clean → dirty_files → WorkingTree::run_command_output), and the branch's checks are still running.

Comment thread CLAUDE.md Resolved
Comment thread tests/integration_tests/remove.rs Resolved
@worktrunk-bot

Copy link
Copy Markdown
Collaborator

Confirming the two gaps I raised are closed in 24a83d4, with the removal test checked by execution rather than by reading it.

I checked out the head, reverted only the four env_remove calls in WorkingTree::run_command_output (working_tree.rs#L318-L321) and left the test, the TempIndex scrub and the list_ignored_entries scrub in place. The test fails, and it fails on the data-safety path rather than incidentally: wt remove other --yes prints Removing other worktree & branch in background (same commit as main) and deletes a worktree holding uncommitted changes, no --force and no warning. Restoring the four lines turns it green. That pins ensure_clean → dirty_files → run_command_output, which the merge test did not.

That result bears on the assertion-strength point in the review just posted: the unscrubbed path today succeeds rather than errors, so !output.status.success() does discriminate as things stand — the failure mode it can't distinguish is a future one, where the removal errors before reaching the gate. Worth tightening for that reason, not because the test is currently vacuous.

The changelog's second ### Fixed entry covers the wt remove half, so the more severe of the two fixes is findable by someone scanning ### Fixed.

test (linux), code-coverage and codecov/patch are green at this head; macOS and Windows are still running.

Assert the gate's own "has uncommitted changes" text so the regression
fails if removal errors for another reason under an inherited GIT_DIR.
Document that TempIndex sets GIT_INDEX_FILE rather than removing it.

Co-authored-by: Cursor <cursoragent@cursor.com>
@Duang777

Copy link
Copy Markdown
Contributor Author

Addressed the two follow-ups on 24a83d4 in 08591da:

  • Remove regression now asserts the dirty-gate message (has uncommitted changes), not just !success
  • CLAUDE.md clarifies that TempIndex::command sets GIT_INDEX_FILE rather than removing it

Still holding for @max-sixty on the deletion-gate surface.

@worktrunk-bot

Copy link
Copy Markdown
Collaborator

Both follow-ups are closed in 08591da, and the assertion lands on the right message: has uncommitted changes is the dirty gate's own text, rendered at error.rs#L752 as Cannot remove worktree: <branch> has uncommitted changes — the <bold> wrap covers only the branch name, so the substring is contiguous whether or not color is on. The test now fails if the removal is refused for any other reason, which was the gap. The CLAUDE.md line matches TempIndex::command's actual behavior now (sets GIT_INDEX_FILE, removes the other three).

Checks at this head: test (linux), test (macos), test (windows), code-coverage and codecov/patch all pass; only the advisory affected tests (macos|windows) are still pending.

Nothing further from me — the verdict is still @max-sixty's, and the CHANGES_REQUESTED review stands.

max-sixty added a commit to max-sixty/tend that referenced this pull request Sep 13, 2026
Every review on a PR added three `tend-mention` rows to its checks, and
on a fork PR all three were skipped — e.g.
max-sixty/worktrunk#4082. GitHub lists every job
of a PR event's run among the PR's checks, skipped jobs included, and a
`pull_request_review` run of `tend-mention` could only ever execute
`relay`: `verify` and `handle` run on the `repository_dispatch` the
relay sends.

The relay now lives in a generated `tend-mention-relay.yaml`, the only
workflow subscribed to `pull_request_review` and
`pull_request_review_comment`. A review adds one row: green on a
same-repo PR, skipped on a fork PR. One row is the floor while anything
listens to review events, since `on:` can't filter forks and a workflow
has no top-level `if`.

- `generate_all` emits the relay alongside `mention` and drops it when
`mention` is disabled. Like `codex-auth-refresh`, it sits outside
`GENERATORS` (it runs no agent) and has its own
`workflows.mention-relay` key for `enabled` and job overrides; an
existing `workflows.mention.jobs.relay` override now warns as not found.
- The relay job is unchanged apart from its `if`, which loses the
event-name check the split makes redundant. The trigger comment on why
`pull_request_review_comment` skips `created` is rewritten: its old
rationale, a cancelled `handle` posting on the PR head, predates the
relay.
- Tests that assume every generated file runs the agent filter through a
`without_relay` helper, and a new snapshot covers the relay file.

Adopters pick up the new file on their nightly regen after the next
release.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

https://claude.ai/code/session_01CxRxDRznNJKdTBwHB5kwHt

> _This was written by Claude Code on behalf of max-sixty_

---------

Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
@max-sixty

Copy link
Copy Markdown
Owner

@worktrunk-bot

  • under what conditions do we scrub these vars exactly?
  • is there a generalizable list of cars to scrub, rather than this list of 3 (or 4 in one place?)

@worktrunk-bot

Copy link
Copy Markdown
Collaborator

Both answers below; the second one turns out to be a Cmd limitation rather than a policy difference, and removing it collapses all three hand-rolled lists into the existing shared one.

When we scrub

The discriminator is who chose the child's working directory, and after this PR it splits four sites two ways:

Scrub — the cwd names a worktree wt resolved, so an inherited GIT_DIR would override that choice:

Keep — the child runs where the user already was, so the inherited context is the user's context:

The Repository::run_command case is the one that reads like an exception but isn't: it does set a cwd, to self.discovery_path — the path the repository was discovered from, i.e. wherever the user invoked wt. That holds for every production Repository: the only non-test Repository::at caller re-derives from repo.discovery_path(). So repo-level plumbing never points somewhere the user didn't, and worktree-level plumbing almost always does.

The generalizable list already exists

It's INHERITED_GIT_PATH_VARS — GIT_DIR, GIT_WORK_TREE, GIT_COMMON_DIR, GIT_INDEX_FILE, GIT_OBJECT_DIRECTORY — already consumed by scrub_git_discovery_env_vars, Cmd::scrub_git_discovery_env, and testing::scrub_git_path_vars, and list_ignored_entries in this very diff uses it.

The 3-and-4-var hand-rolls aren't a narrower policy. They're a workaround for an ordering artifact in Cmd: apply_common_settings applies every env (L1332) and then every env_remove (L1335), so on one Cmd a removal beats a set no matter what order the builder was called in. Both of these sites set one of the five themselves — TempIndex its own GIT_INDEX_FILE, with_object_store_env a redirected repo's GIT_OBJECT_DIRECTORY — so the shared helper would have clobbered their own values, not just the inherited ones. Hence the subsetting, and hence the paragraph of CLAUDE.md explaining it.

Making Cmd hold one call-ordered list of env mutations instead of a set-list plus a remove-list removes the reason. Then .scrub_git_discovery_env() followed by .env(…) means exactly "drop whatever was inherited, keep what I chose", every site uses the one list, and the CLAUDE.md paragraph shrinks back to the single rule.

I have this building and green locally on 08591da: clippy clean, both new regression tests still pass (they're what pin the behaviour), plus the full merge:: + remove:: integration suites (279 tests) and cargo test --lib --bins.

Diff
--- a/src/shell_exec.rs
+++ b/src/shell_exec.rs
@@ struct Cmd
-    envs: Vec<(OsString, OsString)>,
-    env_removes: Vec<OsString>,
+    /// Environment mutations in call order: `Some(value)` sets, `None`
+    /// removes. One ordered list rather than a set list plus a remove list so
+    /// a later [`Cmd::env`] overrides an earlier [`Cmd::env_remove`] — the
+    /// property [`Cmd::scrub_git_discovery_env`] relies on when a caller
+    /// scrubs the whole inherited git context and then supplies its own.
+    env_ops: Vec<(OsString, Option<OsString>)>,

@@ fn apply_common_settings
-        for (key, val) in &self.envs {
-            cmd.env(key, val);
-        }
-        for key in &self.env_removes {
-            cmd.env_remove(key);
+        // In call order, so the last mutation naming a variable wins.
+        for (key, val) in &self.env_ops {
+            match val {
+                Some(val) => cmd.env(key, val),
+                None => cmd.env_remove(key),
+            };
         }

--- a/src/git/repository/working_tree.rs
+++ b/src/git/repository/working_tree.rs
@@ fn run_command_output
-                    .env_remove("GIT_DIR")
-                    .env_remove("GIT_WORK_TREE")
-                    .env_remove("GIT_COMMON_DIR")
-                    .env_remove("GIT_INDEX_FILE"),
+                    .scrub_git_discovery_env(),

@@ impl TempIndex fn command
-            .env_remove("GIT_DIR")
-            .env_remove("GIT_WORK_TREE")
-            .env_remove("GIT_COMMON_DIR")
+            .scrub_git_discovery_env()
             .env("GIT_INDEX_FILE", self.path());

env/env_remove/scrub_git_discovery_env each push onto env_ops instead of their own vector; the rest is doc comments. No existing Cmd sets and removes the same variable, so the reordering is a no-op for every current caller.

One call it surfaces

Using the whole list means worktree-local plumbing now also drops an inherited GIT_OBJECT_DIRECTORY, which the hand-rolled list deliberately kept. When the repository is redirected this is invisible — with_object_store_env re-sets it immediately after the scrub. The delta is the non-redirected case with an inherited value, which git supplies to push-quarantine hooks: worktree-local git would use the real object store while Repository::run_command still forwards the quarantine. I'd argue dropping it is right — it's pinned to the invoking context exactly like GIT_DIR is — but it's a decision worth making deliberately rather than inheriting from the list, so I've left it as-is here rather than pushing anything.

Separately and independent of this PR: GIT_ALTERNATE_OBJECT_DIRECTORIES is not in INHERITED_GIT_PATH_VARS, even though wt always sets it alongside GIT_OBJECT_DIRECTORY and reads the inherited value when building the alternates chain. So every scrub site today removes one half of that pair and keeps the other. Happy to file an issue if that's worth chasing.

@max-sixty

Copy link
Copy Markdown
Owner

ok so can we simplify; canonicalize this?

`apply_common_settings` applied every `env` and then every `env_remove`,
so on one `Cmd` a removal beat a set no matter what order the builder was
called in. That is why the worktree-local scrub sites hand-rolled a 3- or
4-var subset of `INHERITED_GIT_PATH_VARS` instead of calling the shared
helper: both set one of the five themselves (`TempIndex` its own
`GIT_INDEX_FILE`, `with_object_store_env` a redirected repository's
`GIT_OBJECT_DIRECTORY`), and the full scrub would have clobbered their own
values, not just the inherited ones.

Hold one call-ordered list of env mutations instead. Then
`.scrub_git_discovery_env()` followed by `.env(...)` means exactly "drop
whatever was inherited, keep what I chose", every site uses the one list,
and the `CLAUDE.md` paragraph shrinks back to the single rule. No existing
`Cmd` sets and removes the same variable, so the reordering is a no-op for
every current caller.

One behavior delta: worktree-local plumbing now also drops an *inherited*
`GIT_OBJECT_DIRECTORY`, which the hand-rolled list kept. A redirected
repository re-sets its own immediately after the scrub, so the delta is the
non-redirected case with an inherited value, which git supplies to
push-quarantine hooks. It is pinned to the invoking context exactly as
`GIT_DIR` is, so dropping it is consistent with the rest of the list;
recorded as a deliberate call in `scrub_git_discovery_env_vars`'s spec.

`test_env_mutations_apply_in_call_order` pins the ordering property the
collapse rests on — it fails under the old set-then-remove application.
@worktrunk-bot

Copy link
Copy Markdown
Collaborator

Done — pushed as 932d8cc0c. All three hand-rolled lists are gone; every scrub site now calls scrub_git_discovery_env() against the one INHERITED_GIT_PATH_VARS list.

What changed

Cmd now holds a single call-ordered list of env mutations (env_ops: Vec<(OsString, Option<OsString>)>) instead of a set-vector plus a remove-vector that apply_common_settings drained in that fixed order. That fixed order was the whole reason for the subsetting: both worktree-local sites set one of the five vars themselves, so the shared helper would have clobbered their own value, not just the inherited one. With call order, .scrub_git_discovery_env() followed by .env(…) means exactly "drop whatever was inherited, keep what I chose".

The three sites collapse to one line each, and the CLAUDE.md paragraph goes back to the single rule — any spawn site whose cwd names a wt-chosen worktree scrubs; a site needing its own value sets it after.

The GIT_OBJECT_DIRECTORY call — please confirm this is the one you want

This is the one behavior delta, and it's a decision rather than a refactor. Using the whole list means worktree-local plumbing now also drops an inherited GIT_OBJECT_DIRECTORY, which the hand-rolled list deliberately kept.

Where the repository is redirected this is invisible — with_object_store_env re-sets it right after the scrub. The delta is the non-redirected case with an inherited value, which git supplies to push-quarantine hooks: worktree-local git now uses the real object store, where before it used the quarantine. I think dropping it is right — it's pinned to the invoking context exactly as GIT_DIR is, which is the property the whole list is selected on — so I took it rather than carving GIT_OBJECT_DIRECTORY back out, and recorded it as a deliberate call in scrub_git_discovery_env_vars's spec rather than leaving it to be read off the list. Say the word if you'd rather keep it and I'll add the exception back explicitly.

Verification

test_env_mutations_apply_in_call_order pins the ordering property the collapse rests on. I checked it discriminates rather than assuming: restoring the old set-then-remove application in apply_common_settings fails it on a set after the scrub must win, which is the exact way a future refactor would silently strip TempIndex's own GIT_INDEX_FILE.

Locally on 932d8cc: clippy clean across --all-targets, rustdoc link-clean, the two existing regression tests still pass, the full merge:: + remove:: integration suites (279) pass, and cargo test --lib --bins is green but for one pre-existing sandbox failure. CI is the real check on the rest.

The one local failure, and why it isn't this change

copy::tests::test_copy_dir_recursive_does_not_count_a_non_regular_file fails with Os { code: 1, kind: PermissionDenied } at src/copy.rs#L560, where the test binds a UnixListener to build its fixture — the tend sandbox blocks socket(AF_UNIX, …). The two step_copy_ignored integration failures are the same block plus a umask difference (expected 0644, got 0664).

I confirmed rather than assumed: stashing this commit and re-running those tests at the unmodified head 08591da reproduces all three identically. None of them touch env handling.

Merge call still @max-sixty's.

@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.

The collapse itself checks out: apply_common_settings runs the inherited-GIT_* absolutization loop before env_ops, so a scrub anywhere in the builder chain still beats it, and the redirected-repository path re-sets both object-store vars after the scrub. One finding on the rewritten classification.

The exemption for Repository::run_command is justified by a cwd fact the code contradicts. Both CLAUDE.md and the scrub_git_discovery_env_vars spec now say its cwd is discovery_path, "wherever the user invoked wt". discovery_path is whatever Repository::at was handed, and several production sites hand it a worktree wt chose rather than the user's cwd — Repository::at(&worktree_path) for the post-switch hook repo in src/commands/worktree/switch.rs, Repository::at(&spec.worktree_path) in src/commands/run_pipeline.rs, Repository::at(&destination_path) in src/commands/worktree/finish.rs, and Repository::at(ctx.worktree_path) for the pre-remove render repo in src/output/handlers.rs.

The classification's outcome is still right, which is why this is a doc fix rather than a code one: repo-level questions are worktree-agnostic within one repository, and every worktree-scoped answer routes through WorkingTree (current_worktree() is worktree_at(discovery_path)), which this PR makes scrub. But the reason given is what the next implementer applies. Stated as it is, the single rule reads "cwd names a wt-chosen worktree → scrub" with Repository::run_command exempt by construction — so a new repo-level call added at one of those sites looks covered by the exemption when the rule's own test says it isn't. Suggestions inline on both copies naming the real reason.

Verdict still @max-sixty's: the diff decides what wt remove's deletion gate observes, and the GIT_OBJECT_DIRECTORY question the author raised on 932d8cc0c is still open.

Comment thread CLAUDE.md Resolved
Comment thread src/shell_exec.rs Resolved
…ope, not cwd

Both the `CLAUDE.md` rule and the `scrub_git_discovery_env_vars` spec said
repo-level plumbing's cwd is `discovery_path`, "wherever the user invoked
`wt`". That is what the exemption was resting on, and it is false for
several production sites: `Repository::at` is handed a `wt`-chosen worktree
in `commands/worktree/switch.rs` (both hook repos), `commands/run_pipeline.rs`,
`commands/worktree/finish.rs`, and `output/handlers.rs` (the `pre-remove`
render repo), and `run_command_bounded` runs with
`current_dir(&self.discovery_path)`.

The classification's outcome is unchanged — repo-level questions are
worktree-agnostic within one repository, and every worktree-scoped answer
routes through `WorkingTree` (`current_worktree()` is
`worktree_at(discovery_path)`), which this PR makes scrub. But stated as it
was, the single rule read "cwd names a `wt`-chosen worktree → scrub" with
`Repository::run_command` exempt by construction, so a new repo-level call
at one of those sites would look covered by an exemption the rule's own
test says it isn't. Name the real reason instead.

Doc-only; no behavior change.
@max-sixty
max-sixty merged commit 3a6d9c6 into max-sixty:main Sep 14, 2026
43 checks passed
social4hyq pushed a commit to social4hyq/homebrew-core that referenced this pull request Sep 20, 2026
worktrunk 0.78.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

- **Hook scripts read renamed context keys**: the JSON piped to every hook drops `worktree`, `repo_root`, `main_worktree`, and `main_worktree_path` in favour of `worktree_path`, `repo_path`, `repo`, and `primary_worktree_path`. Config templates migrate on load, so hooks written with the old names keep working; scripts reading the JSON, `--execute` templates, and `--var` overrides need updating. (Breaking.) ([#4080](max-sixty/worktrunk#4080))

- **`wt config plugins pi` installs for Pi; oh-my-pi moves to `wt config plugins omp`**: `pi install` wrote an oh-my-pi hook, which Pi never loads; Pi users re-run it to get a Pi extension. Existing oh-my-pi hooks keep working, listed as outdated until `wt config plugins omp install`. (Breaking: scripts that run `wt config plugins pi` for oh-my-pi need `omp`.) [Docs](https://worktrunk.dev/claude-code/#oh-my-pi) ([#4135](max-sixty/worktrunk#4135), thanks @ashebanow)

- **Interactive prompts no longer open with a blank line**: `wt config shell install`, `wt config plugins claude install`, and the commit-message setup offer in `wt merge` began with one. ([#4059](max-sixty/worktrunk#4059))

- **`wt config show` gives a single `wt config shell install` hint**: an outdated wrapper, a fish wrapper at the deprecated `conf.d` path, and missing fish completions each printed their own hint. The zsh `compinit` snippet is now syntax-highlighted. ([#4059](max-sixty/worktrunk#4059))

- **`wt config update --output <path>` confirms the write**: it now prints `✓ Wrote user config migration @ ~/migrated.toml` where it printed nothing. `--output=-` stays silent. ([#4053](max-sixty/worktrunk#4053))

### Fixed

- **Removal no longer discards untracked files hidden by `status.showUntrackedFiles = no`**: under that setting, a worktree holding only untracked files looked clean, so `wt remove`, `wt merge`, and `wt step prune` removed it without `--force`. Safety checks now always count untracked files, and auto-staging warnings list every file they stage. ([#4111](max-sixty/worktrunk#4111), thanks @Duang777)

- **`wt remove` and `wt merge` check the right worktree under an inherited `GIT_DIR`**: run from a `!wt` git alias or a git hook, which pass `GIT_DIR` down, `wt remove` could delete a dirty worktree without `--force`, and `wt merge` could refuse a clean merge. Both now check the worktree they act on. ([#4082](max-sixty/worktrunk#4082), thanks @Duang777)

- **`wt merge` no longer deletes a worktree locked with `git worktree lock`**: the merge completes and prints `Worktree preserved (locked)`. Every Worktrunk removal refuses a locked worktree, even with `--force`; run `git worktree unlock <path>` first. ([#4073](max-sixty/worktrunk#4073), thanks @Duang777)

- **`wt config update` no longer overwrites a config edited while its prompt is open**: it wrote the pre-prompt snapshot over the newer file and reported success. It now fails with the path and leaves the newer file; re-running previews the current contents. ([#4127](max-sixty/worktrunk#4127), thanks @zach-hammad-vs for reporting)

- **`wt step prune` no longer deletes a branch created minutes ago from an older commit**: `--min-age` aged a branch without a worktree by its commit's date, so a new branch off a day-old commit was pruned on the next run. Age now comes from the branch's oldest reflog entry. ([#4077](max-sixty/worktrunk#4077))

- **A comment or blank line above an inline config section no longer breaks the config**: a save or migration that rewrote `commit = { … }` as `[commit]` put that line inside the brackets. `wt switch`, `wt merge`, `wt remove`, and several `wt step` commands then failed with `Failed to load config`; `wt list` warned and ran without the config. Saves also dropped unrecognized keys from inline sections. ([#4120](max-sixty/worktrunk#4120), thanks @zach-hammad-vs for reporting)

- **Config saves keep the trailing comment on a value they rewrite**: a save such as answering the commit-generation offer dropped the comment after each value it rewrote, including one after an inline section's closing brace. ([#4138](max-sixty/worktrunk#4138))

- **Ignored project-config keys warn from every worktree**: an unknown key in `.config/wt.toml`, or one that belongs in user config such as `[merge]`, warned only in the main worktree, so `wt merge` from a linked worktree ignored it silently. ([#4145](max-sixty/worktrunk#4145), thanks @ee-prog for reporting)

- **`wt merge` skips `post-commit` when it removes that hook's worktree**: before, the hook ran in the primary worktree when the removed one sat inside the repository, and otherwise didn't run. The merge now prints `▲ Skipped post-commit`; move work that must finish there to `pre-remove`. ([#4049](max-sixty/worktrunk#4049))

- **`wt switch` recovers from a removed worktree in a bare repository**: `wt switch` and the picker surfaced git's raw `fatal: Unable to read current working directory` instead, and the removed-directory message lacked `wt switch ^`. ([#4067](max-sixty/worktrunk#4067))

- **`wt config shell install fish` puts the wrapper where fish reads it under a custom `$XDG_CONFIG_HOME`**: the wrapper always went to `~/.config/fish/functions/`, so install reported success while `wt switch` changed no directory. On Windows, the fish completion moves from `%APPDATA%\fish\completions` to the wrapper's directory. ([#4107](max-sixty/worktrunk#4107))

- **`wt config shell install zsh` honours `$ZDOTDIR` only when it is absolute**: an empty or relative value resolved against the current directory, so install appended to a `.zshrc` under the current directory and reported success while the file zsh reads went untouched. A non-absolute value now falls back to `$HOME`. ([#4085](max-sixty/worktrunk#4085))

- **`wt config shell install` for Nushell no longer deletes a `wt.nu` under the current directory**: an empty or relative `$XDG_CONFIG_HOME` resolved against it, so install removed a `nushell/vendor/autoload/wt.nu` beneath it unread, as a stale wrapper. It now falls back to `~/.config`, which also fixes unread `tea` logins that let `wt switch pr:<n>` treat a Gitea host as GitHub. ([#4104](max-sixty/worktrunk#4104))

- **`wt switch --create` names the branch a failed worktree add leaves behind**: `git worktree add -b` writes the branch ref before populating the worktree, so a failure in between left the branch with no worktree, and the next attempt reported a name collision. The error now says how to delete or reuse it. ([#4109](max-sixty/worktrunk#4109), thanks @technicalpickles for reporting)

- **`wt config shell install` no longer tells an already-wrapped shell to restart**: reinstalling from a shell with the wrapper loaded, such as after a version bump, printed `↳ Restart shell to activate shell integration`. ([#4059](max-sixty/worktrunk#4059))

- **`wt config shell install` migrates a deprecated `conf.d` fish wrapper when `~/.config/fish/functions` is missing**: before, only `wt config shell install fish` migrated it. `wt config show` now reports that wrapper even when fish isn't on `PATH`. ([#4059](max-sixty/worktrunk#4059))

- **Plugin status and uninstall checks ask the agent CLIs**: `wt config show` could list an installed Claude Code plugin or Gemini CLI extension as not installed, and `wt config plugins claude|codex uninstall` could report success over a marketplace still configured. A repeat Claude uninstall now runs both removals instead of stopping at `Plugin not installed`. ([#4048](max-sixty/worktrunk#4048), [#4054](max-sixty/worktrunk#4054))

- **`wt config plugins opencode install` no longer writes the plugin into the current directory**: with `OPENCODE_CONFIG_DIR` set but empty, it wrote `plugins/worktrunk.ts` there, typically inside a repository, reporting success though OpenCode never saw it. An empty value now counts as unset. ([#4084](max-sixty/worktrunk#4084))

- **The OpenCode plugin clears its activity marker when OpenCode 1 disposes it**: only explicit session deletion cleared it, so a finished session kept its `💬` and `wt list` showed it as active until `wt config state marker clear` was run by hand. ([#4129](max-sixty/worktrunk#4129), thanks @drewdas for reporting)

- **`wt config update` migrates `[ci] platform` into a `[forge]` section that only sets `hostname`**: that config, common with GitHub Enterprise and self-hosted GitLab, kept the deprecated key with no deprecation warning. ([#4061](max-sixty/worktrunk#4061))

- **Deprecated keys in an inline `[projects]` entry now migrate**: `"example.com/org/repo" = { merge = { no-ff = true } }` skipped the migration the section form got, so the per-project setting was ignored. ([#4122](max-sixty/worktrunk#4122), thanks @zach-hammad-vs for reporting)

- **A deprecated config section the migration can't rewrite now warns**: `select = "not a table"`, or a `[select]` whose `[switch.picker]` destination is already set, was ignored without a message. It now reports `unknown field select (will be ignored)`. ([#4121](max-sixty/worktrunk#4121), thanks @zach-hammad-vs for reporting)

- **`wt config update` no longer changes what a template renders**: it could rename `{{ repo_root }}` inside a quoted s

See merge request: Harmonybrew/homebrew-core!20435
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.

wt merge fails with a false conflict against a clean target when GIT_DIR is inherited

3 participants