Repository navigation
fix(git): run diffs through plumbing so user git config can't change what wt reads - #4146
Conversation
…e them Porcelain `git diff` reads display configuration that changes what wt parses. With `diff.relative = true`, `wt remove <branch>` run from a subdirectory deleted an unmerged branch whose changes sat outside it, as "no added changes". `color.ui = always` and `diff.external` put escape codes or an external tool's output into the commit, squash, and summary prompts. Every diff wt parses, counts, caches, renders, or prompts with now runs `diff-tree`, `diff-index`, or `diff-files`, which ignore that configuration. `PreparedDiff` gains staged and commit-pair sides, restores the `git diff` defaults plumbing lacks (rename detection, textconv, hidden intent-to-add entries), ends revisions with `--`, and replaces `DIFF_PREFIX_OVERRIDES`. Branch previews diff from the resolved merge base, because `diff-tree --merge-base` refuses several merge bases. Also: - `main…±` detects renames whatever `diff.renames` says, and under sparse checkout resolves its pathspecs from the repository root. - The staged diff on an unborn branch compares against the empty tree of the repository's object format, so a SHA-256 repository can make its first commit. - `has-added-changes` and `diff-stats` cache entries take a new key prefix, retiring values the porcelain diffs may have computed wrongly. - CLAUDE.md documents the plumbing rule and the traps it has. `wt step diff` keeps porcelain `git diff`, since it shows the user git's own view. `has_staged_changes` and the `git status` checks are left to #4112, which rewrites them. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
`wt merge --no-ff` and `wt step push --no-ff` build the merge commit with `git commit-tree`, which ignores `commit.gpgSign`, so users who sign every commit got an unsigned merge where `git merge --no-ff` would have signed it. The commit now passes `-S` when the setting is on. Also: - `wt step prune` reads branch reflogs with `--no-show-signature`, so `log.showSignature` no longer runs a signature check per entry or puts its output between the selectors it parses. - The summary-cache mock in the list tests hashes the same plumbing diff that `compute_combined_diff` produces. - CLAUDE.md's structured-output table recommends `--porcelain=v2 -z`; without `-z`, v2 prints paths relative to the cwd. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
The `plumbing-` prefix on `has-added-changes` and `diff-stats` keys retired entries the porcelain diffs may have written wrong. Both keys include the target's tip SHA, so such an entry stops being read once the target moves; the prefix only named an implementation detail forever. The CLAUDE.md section keeps the rule and where it lives. The three-dot pitfall moves to `Repository::prepare_diff`, and the other pitfalls already sit beside the code that handles them. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
`wt step rebase` and the rebase inside `wt merge` ran `git rebase <target>` under the user's config. With `rebase.updateRefs = true`, that also rewrote every other local branch whose tip sat inside the rebased range, so rebasing one worktree's branch moved branches `wt` was never asked to touch. The rebase now passes `--no-update-refs`. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
`wt step commit --dry-run` stages into a `TempIndex` and passed its path down, so `PreparedDiff` carried an `index_file` beside the `TempIndex` source it already had. The dry run now passes the `TempIndex` itself, `PreparedDiff` borrows it, and `TempIndex::prepare_diff` / `prepare_staged_diff` build diffs from it. The staged diff also picks up `TempIndex`'s git-discovery scrub, which a relocated worktree read needs. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
worktrunk-bot
left a comment
There was a problem hiding this comment.
submodule.<name>.ignore still reaches every tree diff except the one this PR fixed. has_added_changes_by_sha gets --ignore-submodules=none; PreparedDiff::capture's diff-tree arm, changed_files, and branch_diff_stats do not. With submodule.<name>.ignore = all set (repo config or .gitmodules), a branch whose only change is a submodule bump renders an empty committed-diff preview, reports main…± as no change, and hands wt step commit / wt step squash an empty diff to describe. On git 2.55 both git diff-tree -r --shortstat --find-renames <base> <head> -- and git diff-tree -r --name-only <base> <head> -- return nothing under that config, and adding --ignore-submodules=none restores the gitlink. Suggestion inline on the shared capture arm; changed_files and branch_diff_stats need the same flag. The --cached and working-tree arms are a separate decision — none there also reports dirty submodule worktrees, so dirty is the closer equivalent if you want gitlink changes without that.
codecov/patch is red at 97.75% (261/267) against the base's 98.31%, which CLAUDE.md gates the merge on. Four of the six misses look closeable: PreparedDiff::stream's --cached arm is unreachable (stream has one caller, wt step diff, which always builds a working-tree diff), and has_added_changes_by_sha's non-0/1 exit branch is reachable from a test passing an unresolvable SHA. Dropping the first and covering the second takes the patch to 264/266 = 99.25%, above the base target. The remaining two read as the hand-over case: WorktreeDiffState::Clean => Ok(None) is unreachable because both callers already return early on Clean — a relocated pre-existing miss — and the no-merge-base bail! in the upstream preview has no cheap trigger.
Not approving: has_added_changes_by_sha is the gate that decides whether wt remove deletes an unmerged branch (IntegrationReason::NoAddedChanges in src/git/mod.rs), and .claude/skills/running-tend/references/review-pr.md — "Data-Loss Surface: Hold for Human Review" — holds that surface for a human. The change itself reads as strictly safer than what it replaces: diff-tree --quiet can only report more change than git diff --name-only did, and a non-0/1 exit now errors instead of being read as "no changes".
Plumbing still honors `submodule.<name>.ignore`, so a branch whose only change is a submodule bump could read as having no added changes. Every plumbing diff now passes `--ignore-submodules=none`. Streaming moves from `PreparedDiff` to `TempIndex::stream_diff`, its only caller, and a test covers the integration check's error branch. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
worktrunk-bot
left a comment
There was a problem hiding this comment.
is_squash_merged_via_patch_id still lets submodule.<name>.ignore decide whether wt remove deletes a branch. Both of its diffs run without the new flag — the branch side, patch_ids_from(&["diff-tree", "-p", &merge_base, branch], None), and the target side, patch_ids_from(&["diff-tree", "--stdin", "-p"], ...) — so with submodule.sub.ignore = all the gitlink drops out of both. On git 2.55, git diff-tree -p <base> <head> over a submodule-bump commit prints nothing under that config and the full hunk with --ignore-submodules=none; the --stdin form emits no line at all for such a commit, so it contributes no patch-id.
That turns into a false PatchIdMatch: a branch that changes file A and bumps a submodule hashes to the same patch-id as a target commit that only changed A, so check_integration reports it integrated and wt remove / wt step prune delete it along with the submodule bump that never landed. Same shape as the has_added_changes_by_sha case this commit fixes, on the same deletion gate. Both invocations need the flag — one side alone makes the patch-ids incomparable under that config.
One display-only site is also uncovered: batch_fetch_stats in src/commands/picker/log_formatter.rs (["diff-tree", "--numstat", "-r", "--root", "--stdin"]) renders a submodule-bump commit as +0 −0 in the picker's log pane.
Happy to push both as a commit if you want it in this PR.
…check Both patch-id diffs ran without `--ignore-submodules=none`, so under `submodule.<name>.ignore = all` a branch that edits a file and bumps a submodule matched a target commit carrying only the file edit, and `wt remove` / `wt step prune` treated it as integrated. The picker's per-commit log stats get the same flag. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
|
Fixed in 5590228, no need to push. Both patch-id diffs in
|
worktrunk-bot
left a comment
There was a problem hiding this comment.
Open PR #4100 rewrites is_squash_merged_via_patch_id — the same function this commit fixes — and reintroduces the blind spot one call earlier. It derives the path list that scopes the new candidate rev-list from self.run_command(&["diff-tree", "-r", "-z", "--name-only", &merge_base, branch]), without --ignore-submodules=none, and then early-returns on if branch_paths.is_empty() { return Ok(false); }. Under submodule.<name>.ignore = all that list drops the gitlink, so a branch whose only change is a submodule bump never reaches the patch-id comparison the flag was just added to, and check_integration reports it unintegrated however it landed on the target.
The direction is the safe one — a false negative leaves the branch in place rather than deleting it — so this isn't a second data-loss path. But it is the same submodule.<name>.ignore dependence this PR exists to remove, and the two PRs touch adjacent lines of the function, so whichever merges second has to carry the flag onto that call rather than just resolving the conflict.
Verified on git 2.55
Repo with vendor/sub as a gitlink and submodule."vendor/sub".ignore = all, on a commit that edits f and bumps the submodule:
$ git diff-tree -r -z --name-only $F HEAD | tr '\0' '\n'
f
$ git diff-tree -r -z --name-only --ignore-submodules=none $F HEAD | tr '\0' '\n'
f
vendor/sub
The same repo confirms this commit's own two invocations: diff-tree --patch --ignore-submodules=none emits the 160000 hunk for the nested path with no -r (patch output implies recursion), and the --stdin form emits it too.
|
Both patch-id sides and That makes it the only remaining site where a
Built at this head, on a branch whose only change is a submodule bump under The fix is the arg set let base = self.index_base()?;
Ok(self
.run_command(&[
"diff-index",
"--cached",
"--quiet",
"--ita-invisible-in-index",
"--ignore-submodules=none",
"--end-of-options",
&base,
"--",
])
.is_err())Both extras earn their place: without Pre-existing and not a data-loss path, so it doesn't have to ride here — happy to push it to this branch or leave it for a follow-up. Repro (git 2.55, wt built at 5590228)git init -q sub && cd sub && for n in 1 2 3; do echo s$n > s; git add s; git commit -qm s$n; done; cd ..
git init -q repo && cd repo
echo one > file; printf '[submodule "sub"]\n\tpath = sub\n\turl = ../sub\n' > .gitmodules
git add file .gitmodules && git commit -qm base
git clone -q ../sub sub && (cd sub && git checkout -q <C1>)
git update-index --add --cacheinfo 160000,<C1>,sub && git commit -qm "add submodule at C1"
git switch -q --create feature
git update-index --cacheinfo 160000,<C2>,sub && git commit -qm "bump to C2"
git update-index --cacheinfo 160000,<C3>,sub && git commit -qm "bump to C3"
git config submodule.sub.ignore all
wt step squashAt this head: With |
… deletion code (#4148) The data-loss hold in the tend review reference fired on proximity: a diff that edited a file containing a deletion command, or code near the force-delete path, was held for human review. That held #4146, which made the branch-deletion check stricter and which the reviewer itself called safer than what it replaced. The hold now fires on what a diff can do: make worktrunk destroy something it used to keep, by adding a deletion, widening what an existing one can delete, or loosening a check that gates one (the dirty-worktree check, the integration check behind `wt remove`'s branch deletion). The command list stays as examples of where deletions live, a held review names how the diff could make a deletion destroy more, and the regenerable / throwaway-environment bound is unchanged. <details><summary>Eval: old vs new wording, whole reference pasted in</summary> | Case | Expected | Old | New | |---|---|---|---| | Stricter `has_added_changes_by_sha` (the #4146 change) | approve | 0/3 | 3/3 | | Patch-id fix that stops a false squash-merge match | approve | 0/3 | 3/3 | | Reworded `wt remove -D` warning in a file calling `remove_dir_all` | approve | 0/3 | 3/3 | | Trash-sweep threshold one day → seven days | approve | — | 3/3 | | Dirty check swapped to a command that misses untracked files | hold | 3/3 | 3/3 | | Squash-merge match loosened to "same file paths" | hold | 3/3 | 3/3 | | `git worktree remove --force --force` for locked worktrees | hold | 3/3 | 3/3 | | `rename_into_trash` moved above `ensure_clean` | hold | — | 7/7 | | `wt step prune` path taken from the rendered `worktree-path` template | hold | — | 7/7 | The last two include four runs each of a variant that leaves the consequence out of the case. A third arm without a "code on the deletion path gets an ordinary review" sentence scored the same, so that sentence was cut. worktrunk-bot's suggested fourth trigger ("changes what an existing deletion targets or when it fires relative to its gate") held the reorder and retarget cases 3/3 too, and held the narrowing patch-id fix in 1 of 3 runs. </details> > _This was written by Claude Code on behalf of max-sixty_ 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
Follow-up to #4146. Plumbing diffs ignore the user's diff display configuration but still honor `submodule.<name>.ignore`, from repository config or `.gitmodules`. #4146 passed `--ignore-submodules=none` at each of about ten call sites, and review twice found sites that missed it. `PlumbingDiff` in `src/git/diff.rs` now builds every `diff-tree`, `diff-index`, and `diff-files` invocation, and `PlumbingDiff::args` always adds the flag. `test_plumbing_diffs_are_built_by_plumbing_diff`, beside the other source-text guards, fails when a file under `src/` or `tests/` spells one of those commands as a string literal, so a new call site can't skip the override. The call sites and CLAUDE.md's plumbing paragraph move to it; behavior is unchanged apart from argument order. > _This was written by Claude Code on behalf of max-sixty_ 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
`has-added-changes` and `merge-add-probe` are keyed on the branch and target tips with no TTL and no invalidation rule, so an entry answers for whatever code wrote it until its key recurs — which on a finished branch is never. #4146 moved every diff `wt` parses onto plumbing so display config can no longer change what it reads. The porcelain reads it replaced wrote those two kinds, and under `diff.relative` or `submodule.<name>.ignore` they recorded a branch with changes as having none. Nothing clears the cache on upgrade, so the first `wt remove` after installing the fix still reads the old answer and deletes an unmerged branch without `--force`, reporting `no added changes on main`. Reproduced against the fixed binary with a hand-written pre-upgrade entry. `CACHE_EPOCH` in `src/cache.rs` versions what the cached values mean. `ensure_epoch` runs from `cache_dir`, the one funnel every read and write passes through, so no caller reaches a stale entry ahead of the check; a tree stamped with a different epoch is discarded whole. That makes a future generator change one constant bump rather than a rename per affected kind. The stamp is a non-`.json` file at the cache root, so the per-kind sweeps behind `wt config state cache clear` leave it alone. `TestRepo::assemble` stamps the tree it builds: a test that seeds `.git/wt/cache/` by hand means entries this version produced, and unstamped they would be swept before the test read them. `test_remove_branch_only_unmerged_ignores_cache_from_an_older_epoch` covers the upgrade, and fails without the change. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
`has-added-changes` and `merge-add-probe` are keyed on the branch and target tips with no TTL and no invalidation rule, so an entry answers for whatever code wrote it until its key recurs — which on a finished branch is never. #4146 moved every diff `wt` parses onto plumbing so display config can no longer change what it reads. The porcelain reads it replaced wrote those two kinds, and under `diff.relative` or `submodule.<name>.ignore` they recorded a branch with changes as having none. Nothing clears the cache on upgrade, so the first `wt remove` after installing the fix still reads the old answer and deletes an unmerged branch without `--force`, reporting `no added changes on main`. Reproduced against the fixed binary with a hand-written pre-upgrade entry. `CACHE_EPOCH` in `src/cache.rs` versions what the cached values mean. `ensure_epoch` runs from `cache_dir`, the one funnel every read and write passes through, so no caller reaches a stale entry ahead of the check; a tree stamped with a different epoch is discarded whole. That makes a future generator change one constant bump rather than a rename per affected kind. The stamp is a non-`.json` file at the cache root, so the per-kind sweeps behind `wt config state cache clear` leave it alone. `TestRepo::assemble` stamps the tree it builds: a test that seeds `.git/wt/cache/` by hand means entries this version produced, and unstamped they would be swept before the test read them. `test_remove_branch_only_unmerged_ignores_cache_from_an_older_epoch` covers the upgrade, and fails without the change. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
`has-added-changes` and `merge-add-probe` are keyed on the branch and target tips with no TTL and no invalidation rule, so an entry answers for whatever code wrote it until its key recurs — which on a finished branch is never. #4146 moved every diff `wt` parses onto plumbing so display config can no longer change what it reads. The porcelain reads it replaced wrote those two kinds, and under `diff.relative` or `submodule.<name>.ignore` they recorded a branch with changes as having none. Nothing clears the cache on upgrade, so the first `wt remove` after installing the fix still reads the old answer and deletes an unmerged branch without `--force`, reporting `no added changes on main`. Reproduced against the fixed binary with a hand-written pre-upgrade entry. `CACHE_EPOCH` in `src/cache.rs` versions what the cached values mean. `ensure_epoch` runs from `cache_dir`, the one funnel every read and write passes through, so no caller reaches a stale entry ahead of the check; a tree stamped with a different epoch is discarded whole. That makes a future generator change one constant bump rather than a rename per affected kind. The stamp is a non-`.json` file at the cache root, so the per-kind sweeps behind `wt config state cache clear` leave it alone. `TestRepo::assemble` stamps the tree it builds: a test that seeds `.git/wt/cache/` by hand means entries this version produced, and unstamped they would be swept before the test read them. `test_remove_branch_only_unmerged_ignores_cache_from_an_older_epoch` covers the upgrade, and fails without the change. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
`has-added-changes` and `merge-add-probe` are keyed on the branch and target tips with no TTL and no invalidation rule, so an entry answers for whatever code wrote it until its key recurs — which on a finished branch is never. #4146 moved every diff `wt` parses onto plumbing so display config can no longer change what it reads. The porcelain reads it replaced wrote those two kinds, and under `diff.relative` or `submodule.<name>.ignore` they recorded a branch with changes as having none. Nothing clears the cache on upgrade, so the first `wt remove` after installing the fix still reads the old answer and deletes an unmerged branch without `--force`, reporting `no added changes on main`. Reproduced against the fixed binary with a hand-written pre-upgrade entry. `CACHE_EPOCH` in `src/cache.rs` versions what the cached values mean. `ensure_epoch` runs from `cache_dir`, the one funnel every read and write passes through, so no caller reaches a stale entry ahead of the check; a tree stamped with a different epoch is discarded whole. That makes a future generator change one constant bump rather than a rename per affected kind. The stamp is a non-`.json` file at the cache root, so the per-kind sweeps behind `wt config state cache clear` leave it alone. `TestRepo::assemble` stamps the tree it builds: a test that seeds `.git/wt/cache/` by hand means entries this version produced, and unstamped they would be swept before the test read them. `test_remove_branch_only_unmerged_ignores_cache_from_an_older_epoch` covers the upgrade, and fails without the change. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
`has-added-changes` and `merge-add-probe` are keyed on the branch and target tips with no TTL and no invalidation rule, so an entry answers for whatever code wrote it until its key recurs — which on a finished branch is never. #4146 moved every diff `wt` parses onto plumbing so display config can no longer change what it reads. The porcelain reads it replaced wrote those two kinds, and under `diff.relative` or `submodule.<name>.ignore` they recorded a branch with changes as having none. Nothing clears the cache on upgrade, so the first `wt remove` after installing the fix still reads the old answer and deletes an unmerged branch without `--force`, reporting `no added changes on main`. Reproduced against the fixed binary with a hand-written pre-upgrade entry. `CACHE_EPOCH` in `src/cache.rs` versions what the cached values mean. `ensure_epoch` runs from `cache_dir`, the one funnel every read and write passes through, so no caller reaches a stale entry ahead of the check; a tree stamped with a different epoch is discarded whole. That makes a future generator change one constant bump rather than a rename per affected kind. The stamp is a non-`.json` file at the cache root, so the per-kind sweeps behind `wt config state cache clear` leave it alone. `TestRepo::assemble` stamps the tree it builds: a test that seeds `.git/wt/cache/` by hand means entries this version produced, and unstamped they would be swept before the test read them. `test_remove_branch_only_unmerged_ignores_cache_from_an_older_epoch` covers the upgrade, and fails without the change. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
`has-added-changes` and `merge-add-probe` are keyed on the branch and target tips with no TTL and no invalidation rule, so an entry answers for whatever code wrote it until its key recurs — which on a finished branch is never. #4146 moved every diff `wt` parses onto plumbing so display config can no longer change what it reads. The porcelain reads it replaced wrote those two kinds, and under `diff.relative` or `submodule.<name>.ignore` they recorded a branch with changes as having none. Nothing clears the cache on upgrade, so the first `wt remove` after installing the fix still reads the old answer and deletes an unmerged branch without `--force`, reporting `no added changes on main`. Reproduced against the fixed binary with a hand-written pre-upgrade entry. `CACHE_EPOCH` in `src/cache.rs` versions what the cached values mean. `ensure_epoch` runs from `cache_dir`, the one funnel every read and write passes through, so no caller reaches a stale entry ahead of the check; a tree stamped with a different epoch is discarded whole. That makes a future generator change one constant bump rather than a rename per affected kind. The stamp is a non-`.json` file at the cache root, so the per-kind sweeps behind `wt config state cache clear` leave it alone. `TestRepo::assemble` stamps the tree it builds: a test that seeds `.git/wt/cache/` by hand means entries this version produced, and unstamped they would be swept before the test read them. `test_remove_branch_only_unmerged_ignores_cache_from_an_older_epoch` covers the upgrade, and fails without the change. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
`has-added-changes` and `merge-add-probe` are keyed on the branch and target tips with no TTL and no invalidation rule, so an entry answers for whatever code wrote it until its key recurs — which on a finished branch is never. #4146 moved every diff `wt` parses onto plumbing so display config can no longer change what it reads. The porcelain reads it replaced wrote those two kinds, and under `diff.relative` or `submodule.<name>.ignore` they recorded a branch with changes as having none. Nothing clears the cache on upgrade, so the first `wt remove` after installing the fix still reads the old answer and deletes an unmerged branch without `--force`, reporting `no added changes on main`. Reproduced against the fixed binary with a hand-written pre-upgrade entry. `CACHE_EPOCH` in `src/cache.rs` versions what the cached values mean. `ensure_epoch` runs from `cache_dir`, the one funnel every read and write passes through, so no caller reaches a stale entry ahead of the check; a tree stamped with a different epoch is discarded whole. That makes a future generator change one constant bump rather than a rename per affected kind. The stamp is a non-`.json` file at the cache root, so the per-kind sweeps behind `wt config state cache clear` leave it alone. `TestRepo::assemble` stamps the tree it builds: a test that seeds `.git/wt/cache/` by hand means entries this version produced, and unstamped they would be swept before the test read them. `test_remove_branch_only_unmerged_ignores_cache_from_an_older_epoch` covers the upgrade, and fails without the change. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
`has-added-changes` and `merge-add-probe` are keyed on the branch and target tips with no TTL and no invalidation rule, so an entry answers for whatever code wrote it until its key recurs — which on a finished branch is never. #4146 moved every diff `wt` parses onto plumbing so display config can no longer change what it reads. The porcelain reads it replaced wrote those two kinds, and under `diff.relative` or `submodule.<name>.ignore` they recorded a branch with changes as having none. Nothing clears the cache on upgrade, so the first `wt remove` after installing the fix still reads the old answer and deletes an unmerged branch without `--force`, reporting `no added changes on main`. Reproduced against the fixed binary with a hand-written pre-upgrade entry. `CACHE_EPOCH` in `src/cache.rs` versions what the cached values mean. `ensure_epoch` runs from `cache_dir`, the one funnel every read and write passes through, so no caller reaches a stale entry ahead of the check; a tree stamped with a different epoch is discarded whole. That makes a future generator change one constant bump rather than a rename per affected kind. The stamp is a non-`.json` file at the cache root, so the per-kind sweeps behind `wt config state cache clear` leave it alone. `TestRepo::assemble` stamps the tree it builds: a test that seeds `.git/wt/cache/` by hand means entries this version produced, and unstamped they would be swept before the test read them. `test_remove_branch_only_unmerged_ignores_cache_from_an_older_epoch` covers the upgrade, and fails without the change. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Cuts 0.79.0 from `75baa2cd3`. Minor bump: `cargo semver-checks` reports five breaking library lints, so patch is disallowed pre-1.0. Two commits — the changelog and version bump, plus one fix the release's data-loss review turned up. ## The cache fix `has-added-changes` and `merge-add-probe` are keyed on the branch and target tips with no TTL and no invalidation, so an entry answers for whatever code wrote it until its key recurs — which on a finished branch is never. #4146 moved every diff `wt` parses onto plumbing so display config can no longer change what it reads. The porcelain reads it replaced wrote those two kinds, and under `diff.relative` or `submodule.<name>.ignore` they could record a branch's changes as absent. Nothing clears the cache on upgrade, so a poisoned entry outlives the fix: `wt remove` reads the old answer and deletes the branch without `-D`. The exposure is narrow — it needs one of those two settings, and for `diff.relative` also a run from a subdirectory the branch's changes sit outside. The commits stay in the object store; it's the ref that goes. But nothing about the upgrade clears it, so for an affected repository the fix in #4146 does nothing until the cache is discarded. Reproduced against the fixed binary with a hand-written pre-upgrade entry: ``` ✓ Removed branch feature (no added changes on main, ⊂) branch still present? DELETED ``` `CACHE_EPOCH` in `src/cache.rs` versions what the cached values mean. `ensure_epoch` runs from `cache_dir`, the one funnel every read and write passes through, and discards a tree stamped with a different epoch. The lock spans the removal, not just the bookkeeping, because `wt list` fans the SHA-keyed reads over a thread pool. The sweep attempts every kind and returns the first error, so one undeletable directory doesn't strand the rest in `read_dir` order. Both `wt config state clear` and `wt config state cache clear` drop the stamp with the entries it describes, so a cleared tree re-stamps on the next command rather than vouching for whatever lands there next. `UNVERSIONED_KINDS` exempts `summary`, `ci-status` and `pr-number`, so an upgrade doesn't charge a model call per branch and a forge round-trip for a diff fix. `ci-status` and `pr-number` hold the forge's own answer, so no change to how `wt` computes things can make them wrong. `summary` is exempt on weaker grounds, stated as such in the docstring: its key hashes the diff, but the prompt template and `llm::prepare_diff`'s filtering sit downstream of that hash, so rewording the prompt does leave a stale summary — accepted because the value is display-only, and closing it means hashing the rendered prompt rather than bumping the epoch. Known residual, deliberately deferred: the stamp records the last worktrunk to *check* a tree, not what wrote each entry, so a 0.78.0 binary run afterwards writes porcelain answers this one trusts. Closing that means putting the epoch in each entry's path, which invalidates by construction and costs the same in a later release. It is named in the `CACHE_EPOCH` comment. `TestRepo::assemble` stamps the tree it builds, since a test that seeds `.git/wt/cache/` by hand means entries this version produced. `test_remove_branch_only_unmerged_ignores_cache_from_an_older_epoch` covers the upgrade, a table-driven unit test covers all three stamp states and the exemption, and both clear handlers are pinned against dropping their `clear_epoch` call. Each assertion was checked under mutation rather than left to pass by construction. ## Checks `cargo run -- hook pre-merge --yes` green (4925 tests). This PR runs the full cross-platform matrix itself — `full-tests` on macOS, Linux, Windows and git 2.43.0, plus feature-powerset, nix-flake and the release targets — and `nightly.yaml` re-runs on the merged tip before the tag, since the green run on the cut-from tip predates the cache fix. Changelog verified over three passes against the diffs, the pre-change files, the rendered docs, and a forced `cargo-semver-checks` run. > _This was written by Claude Code on behalf of max-sixty_ 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
The #4146 entry named the two settings but not what else each needed, so it read as though any user with `diff.relative` could lose a branch. Both cases need two conditions at once, verified against the v0.78.0 binary: `diff.relative` *and* a command run from a subdirectory the branch's changes sat entirely outside; `submodule.<name>.ignore` *and* a submodule bump as the branch's only change. The entry now joins each pair with "and" and calls them corner cases. The release skill gains the rule behind that: a correctness or data-loss entry states the conditions the bug needed, joined with "and", established by reproducing against the previous release rather than read off the diff — since a condition assumed is one the entry overstates. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
The #4146 entry ended by telling affected users to run `wt config state cache clear`. A changelog records what changed; it doesn't instruct, so the sentence goes and the entry ends on the change. That leaves the CLAUDE.md paragraph prescribing the very line just removed — "owes its changelog entry a line … telling the reader that `wt config state cache clear` drops them" — so it now routes the concern to the PR description, where the trade is decided. Slimmed while there. The release skill gains the rule, since its existing guidance let an imperative through twice: entries describe; remediation steps belong in the PR description. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
"Entries describe; they don't instruct" contradicted two entries from
recent releases that tell users to reinstall a static file ("Re-run `wt
config plugins opencode install` to pick it up"; "rerun `wt config shell
install` to pick this up"). Those steps are part of how the change
arrives for everyone using the feature, and the release notes are the
only place those users see them.
The rule now keeps them and still excludes what was removed from the
#4146 entry: a step every user of a feature must take is part of what
changed, while remediation for a corner case is advice for the PR
description.
Also adds a missing "as" to the #4146 entry.
Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Removes `CACHE_EPOCH` and the machinery around it, added in #4181. **Time-sensitive:** 0.79.0 is merged to `main` but not tagged and not on crates.io, so the epoch has never reached a user. Landing this before the tag means it never ships. ## What it was protecting Two corner cases in 0.78.0 made `wt remove` delete an unmerged branch without `-D`, each needing two conditions at once. Reproduced against the v0.78.0 binary: - `diff.relative` set **and** the command run from a subdirectory the branch's changes sat entirely outside. Run from the repository root with the same config, 0.78.0 correctly retains the branch. - `submodule.<name>.ignore` set (git config or `.gitmodules`) **and** a submodule bump as the branch's only change. In both, 0.78.0 reports `✓ Removed branch feature (no added changes on main, ⊂)` and 0.79.0 retains it. #4146 fixed how the answer is computed, but 0.78.0 cached its wrong answer keyed on the branch and target tips with no expiry, so the fix can't reach an entry already on disk. ## Why it goes The epoch fires at most once per repository, on the first command after upgrading, and pays off only for a user who hit one of those corner cases *and* has a live cached key *and* then removes that branch. Against that it carried a stamp file, a tree wipe, a global mutex on every cache read and write, a documented hole when two versions share a repository, and a failure path where an undeletable directory left the reader with exactly the entries the wipe existed to discard. So nothing replaces it: a repository that hit one of the corner cases under 0.78.0 keeps that cached answer after upgrading, exactly as it would have kept it on 0.78.0. `wt config state cache clear` drops it for anyone who asks. The changelog entry describes both corner cases and stays descriptive — it names no remediation. ## No new negative behavior 0.78.0 and 0.79.0 read any entry already on disk identically — across `v0.78.0..HEAD` the key functions, the kind set, the consumers of both integration probes, and `check_integration`'s priority order are all unchanged, and no cached struct changed shape. They diverge only on a cache miss, where 0.79.0 is right and 0.78.0 was wrong. So 0.79.0 without the epoch is a strict improvement on 0.78.0, and at worst a tie. ## Also - **Release skill:** two rules. A correctness or data-loss entry states the conditions the bug needed, joined with "and", established by reproducing against the previous release rather than read off the diff — without that, an entry like this one reads as though it fired for everyone. And entries describe: imperative guidance only for a material issue that affects a sizable share of users, which is rare. - **`src/summary.rs`:** keeps the caveat that the summary cache hashes the diff while the prompt sits downstream of that hash, which previously lived only in the docstring this removes. - **`CLAUDE.md`:** records that not versioning the cache is the decision, and that a generator change says in its PR what the old answers get wrong. > _This was written by Claude Code on behalf of max-sixty_ 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
Porcelain
git diffreads display configuration that changes what it reports, andwtparsed its output. Withdiff.relative = true,wt remove <branch>run from a subdirectory deleted an unmerged branch whose changes sat outside that directory, reporting "no added changes".color.ui = alwaysanddiff.externalput escape codes or an external tool's output into the commit, squash, and summary prompts.Every diff
wtparses, counts, caches, renders, or sends to an LLM now runsdiff-tree,diff-index, ordiff-files, which ignore that configuration. This follows the plumbing question raised in the review of #4112.Where to look
src/git/repository/diff.rs:PreparedDiffis the one path for rendered and prompted diffs, with working-tree, staged, and commit-pair sides read from the real index or a borrowedTempIndex. It restores thegit diffdefaults plumbing lacks (rename detection, textconv, hidden intent-to-add entries), overridessubmodule.<name>.ignore(which plumbing still honors), names the output format, and ends revisions with--.DIFF_PREFIX_OVERRIDESis gone.src/git/repository/integration.rs:has_added_changes_by_sharunsdiff-tree --quiet --ignore-submodules=none, and both sides of the patch-id squash-merge check pass--ignore-submodules=nonetoo.BranchDiffSpeccarries a resolveddiff_base, sincediff-treehas no three-dot form and--merge-baserefuses several merge bases. The empty tree follows the repository's object format, so a SHA-256 repository can make its first commit.HEAD±,main…±,changed_files,unmerged_paths, the picker's per-commit log stats, and the commit, squash, and merge diffstats read plumbing too, all with--ignore-submodules=none.main…±sparse pathspecs now resolve from the repository root.Two related fixes where user config meets the commands that write:
wt merge --no-ffbuilds its merge commit withcommit-tree, which ignorescommit.gpgSign; it now passes--gpg-signwhen that setting is on.wt step rebaseandwt mergepass--no-update-refs, sorebase.updateRefscan't move other branches stacked in the rebased range.wt step diffstays porcelain (TempIndex::stream_diff), because it shows the user git's own view.has_staged_changesand thegit statuschecks are untouched, since #4112 rewrites them.Behavior users can see
Picker diff previews, LLM summaries, and prompts no longer follow
diff.external,diff.noprefix, orcolor.ui = always.main…±detects renames whateverdiff.renamessays.Testing
New tests cover branch deletion under
diff.relative, a submodule bump undersubmodule.<name>.ignore = all(including a squash merge that dropped or carried the bump), prompts under hostile diff config, amain/directory beside themaintarget, criss-cross merge bases, intent-to-add entries and renames in the fallback commit message, a SHA-256 first commit, sparse checkout from a subdirectory, a signed--no-ffmerge, and a stacked branch underrebase.updateRefs. Each fails with its fix reverted, except the criss-cross case, whose fix removed the code path it would revert to.diff_tree_failure_is_command_errorcovers the integration check's error branch. Running the suite with a hostile global gitconfig swapped into the test harness leaves only the harness's own porcelain assertions and intended display output failing.🤖 Generated with Claude Code