Skip to content

fix(squash): back up the index with plumbing so hidden submodule changes don't abort the squash - #4303

Merged
max-sixty merged 2 commits into
mainfrom
agent-a52e971975ba8e3b4
Sep 27, 2026
Merged

max-sixty merged 2 commits into
mainfrom
agent-a52e971975ba8e3b4

Conversation

@max-sixty

Copy link
Copy Markdown
Owner

#4192 (unreleased) made has_staged_changes see a staged submodule pointer hidden by submodule.<name>.ignore=all, which sends such a squash into the safety backup. The backup used git stash create, which honors that ignore setting, saw nothing, and returned an empty SHA, so wt step squash and a default-squash wt merge aborted with ✗ git stash create returned empty SHA - no changes to backup. In 0.79.0 a multi-commit squash in that setup succeeded (leaving the pointer out), so this would ship as a regression. The 0.80.0 changelog verification found it.

The backup now snapshots the index with plumbing — write-tree, then commit-tree --no-gpg-sign <tree> -p HEAD, recorded in refs/wt-backup/<branch>'s reflog as before — so no config hides part of it. By the time the backup runs, squash has already staged per its stage mode, so the index is exactly what the squash absorbs; unstaged and untracked files, which the squash leaves in place, are no longer in the backup. --no-gpg-sign keeps the backup from prompting for a signature, as stash create never signed.

test_step_squash_backs_up_submodule_bump_hidden_by_ignore covers the two-commit, one-commit, and commits-cancel-out shapes, each with a hidden staged pointer: all three failed with the stash error before, and now squash including the pointer, with the backup's tree equal to the squash tree and its parent the pre-squash tip. Nine snapshots change only on their Backup created @ <sha> line.

This was written by Claude Code on behalf of max-sixty

max-sixty and others added 2 commits September 26, 2026 23:37
…ges don't abort the squash

Since has_staged_changes reads the index with plumbing (#4192), a staged
submodule pointer bump hidden by `submodule.<name>.ignore=all` counts as
staged, so the squash takes its backup path. The backup ran
`git stash create`, which honors that config, saw nothing, and aborted the
squash with "git stash create returned empty SHA".

The backup now writes the index with `write-tree` and `commit-tree -p HEAD`,
so it holds exactly what the squash commits on top of the pre-squash tip,
whatever the porcelain config hides. Unstaged and untracked files were never
at risk: the squash leaves them in place. The backup commit is unsigned.

Backup SHAs in nine snapshots change with the new commit shape.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@max-sixty
max-sixty merged commit 12efb51 into main Sep 27, 2026
38 checks passed
@max-sixty
max-sixty deleted the agent-a52e971975ba8e3b4 branch September 27, 2026 17:46
@max-sixty max-sixty mentioned this pull request Sep 27, 2026
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) <noreply@anthropic.com>
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.

2 participants