Repository navigation
fix(list): read a stale worktree's rebase state from its registration - #4302
Merged
Merged
Conversation
A detached worktree mid-rebase takes the name of the branch it is
rebasing, found by running `git rev-parse --git-dir` in the worktree and
reading `rebase-{merge,apply}/head-name`. For a stale (prunable) entry
whose directory remains but whose `.git` is gone, that lookup walks up
to whatever repository encloses the directory. A detached worktree
nested inside the main worktree (e.g. `repo/.worktrees/x`) was therefore
named after the main worktree's rebase.
Since #4228 lets `wt step prune` and `wt remove` unregister such
entries, the mislabel reached data: with the main worktree rebasing an
integrated branch, `wt step prune` judged the stale detached entry by
that branch and deleted its registration, leaving commits held only by
its detached HEAD unreferenced; `wt remove <path>` did the same instead
of refusing a detached stale entry.
A stale entry's git dir is its registration `<common>/worktrees/<id>`,
so its rebase state is read from there.
Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
worktrunk-bot
approved these changes
Sep 27, 2026
Merged
max-sixty
added a commit
that referenced
this pull request
Sep 27, 2026
Bumps 0.79.0 → 0.80.0 and adds the `## 0.80.0` changelog section, cut from `12efb5159`. The bump is minor because the library API breaks (see Verification). ## Verification - `cargo run -- hook pre-merge --yes` on the cut tip: 4985 passed. - `nightly.yaml` on `12efb5159`, all jobs green including feature-powerset: https://github.com/max-sixty/worktrunk/actions/runs/36338233859 - `cargo semver-checks check-release -p worktrunk` reports five major-level lints, the removals and signature changes listed in the Internal entry. - Changelog: repeated verification passes against source until one came back clean. Fixed headlines name the condition a bug needed rather than its worst case, and near-zero-reach fixes are folded into two roll-up bullets, per #4295. - Data-loss surface review over `v0.79.0..HEAD` with independent finders. The one real finding, a nested stale detached worktree read as the enclosing repo's rebase so `wt step prune` could unregister it, was fixed in #4302. The review also found a squash regression in the backup path, fixed in #4303. The remaining candidates were adjudicated acceptable and signed off: #4228 unregistering stale worktrees whose directory remains (files stay on disk; the branch is deleted only if integrated), #4206 leaving a detached `HEAD` on Ctrl-C during a slow commit hook, #4251 allowing `--no-squash` merges with untracked files, #4219 dropping `--no-hooks` from the skill example, and #4279's `docker stop` recipe. #4252 closes a submodule data-loss path. > _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.5 (1M context) <[email protected]>
1 task
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A detached worktree mid-rebase takes the name of the branch it is rebasing, found by running
git rev-parse --git-dirfrom the worktree's path. For a stale entry whose directory remains but whose.gitis gone, that lookup walks up to whatever repository encloses the directory, so a detached worktree nested inside the main worktree (e.g.repo/.worktrees/x) was named after the main worktree's rebase.#4228 (unreleased) lets
wt step pruneandwt removeunregister such entries, which turned the mislabel into data loss: with the main worktree rebasing an integrated branch,wt step prunejudged the stale detached entry by that branch and deleted its registration, leaving commits held only by its detached HEAD unreferenced.wt remove <path>did the same instead of refusing. The 0.80.0 release's data-loss review found it; reproduced end-to-end before the fix, and after it prune keeps the entry andwt removerefuses.A stale entry's git dir is its registration
<common>/worktrees/<id>, sofinalize_worktreesnow reads a stale entry's rebase state from there via the existingRepository::registration_at; live detached worktrees still userev-parse.test_finalize_worktree_stale_reads_its_own_rebasecovers both a nested stale entry (must get no label) and a stale entry that is itself mid-rebase (labelled from its registration).