Repository navigation
fix: replace reset --hard with safe read-tree for worktree sync - #1623
Merged
Merged
Conversation
…ee sync `reset --hard` in the no-ff merge path silently discards any tracked-file modifications added between the pre-push dirty check and the sync. Replace with `read-tree -m -u` (two-tree merge) which refuses to overwrite locally modified files, failing safely instead of silently losing work. `reset --keep` would be ideal but can't be used here: after `update-ref`, HEAD already points to the merge commit, so `reset --keep HEAD` sees old==new and is a no-op. Also adds CLAUDE.md guidance to favor data-retaining git operations over destructive ones (e.g., `reset --keep` over `reset --hard` where possible). Co-Authored-By: Claude Opus 4.6 <[email protected]>
Exercise the error handling when read-tree -m -u fails during no-ff merge worktree sync, by locking the target worktree's index file before the merge. Co-Authored-By: Claude Opus 4.6 <[email protected]>
worktrunk-bot
commented
Mar 19, 2026
worktrunk-bot
left a comment
Collaborator
Author
There was a problem hiding this comment.
Lint CI failed — rustfmt wants the assert_eq! on the long line expanded. Pre-existing formatting hook catches it.
Co-Authored-By: Claude <[email protected]>
worktrunk-bot
added a commit
that referenced
this pull request
Mar 19, 2026
The review bot consistently performs full code analysis (10-18 minutes of CI compute) on self-authored PRs, only to stay silent because it cannot approve its own work. Observed 6 times across PRs #1610, #1613, #1614, #1619, #1622, #1623. Add early-exit guidance in step 1 to skip steps 2-4 for self-authored PRs. The bot still monitors CI and resolves threads, but skips the redundant code review that always produces zero visible output. Co-Authored-By: Claude Opus 4.6 <[email protected]>
This was referenced Mar 19, 2026
4 tasks done
max-sixty
pushed a commit
that referenced
this pull request
Mar 19, 2026
## Summary - Add `--recurse-submodules=no` to the local `git push` in `wt merge`/`wt step push` to prevent `submodule.recurse=true` from interfering with worktree-to-worktree ref updates - Add regression tests for both fast-forward and no-ff push with `submodule.recurse=true` config The `reset --hard` fix from the original PR is no longer needed — #1623 replaced `reset --hard` with `read-tree -m -u`, which doesn't recurse into submodules. Closes #1604 ## Test plan - [x] New test `test_push_with_submodule_recurse_config` — verifies fast-forward push succeeds with `submodule.recurse=true` - [x] New test `test_push_no_ff_with_submodule_recurse_config` — verifies no-ff push succeeds with `submodule.recurse=true` - [x] All existing push tests still pass - [x] Lints pass 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: worktrunk-bot <[email protected]> Co-authored-by: Claude Opus 4.6 <[email protected]>
worktrunk-bot
added a commit
that referenced
this pull request
Mar 19, 2026
Reverts the step-1 short-circuit that skipped full analysis on self-authored PRs. The bot catches real issues on its own PRs (e.g., lint failures on #1623), so the review is worth running. Adds explicit "still perform the full review" language to step 4 to prevent future bots from proposing this optimization. Co-Authored-By: Claude Opus 4.6 <[email protected]>
max-sixty
pushed a commit
that referenced
this pull request
Mar 19, 2026
…ble (#1624) ## Summary - Reverts the step-1 short-circuit that skipped full review analysis on self-authored PRs - Adds explicit "still perform the full review" language to step 4 to prevent future bots from proposing this optimization - Self-review catches real issues (e.g., lint failure on #1623) and is intentionally valuable ## Context The original commit incorrectly optimized away self-authored PR reviews based on the observation that they "always produce zero visible output." But silence-means-correct is the expected outcome — the review still catches real problems when they exist. ## Test plan - [ ] Verify next self-authored PR review performs full analysis (steps 2–4) - [ ] Verify the clarified step 4 language prevents future skip-self-review proposals 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: worktrunk-bot <[email protected]> Co-authored-by: Claude Opus 4.6 <[email protected]>
Closed
7 tasks
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.
Summary
reset --hardwithread-tree -m -u(two-tree merge) in the no-ff merge worktree sync path — refuses to overwrite locally modified tracked files instead of silently discarding them (TOCTOU safety)Follow-up to #1619 per review feedback.
Details
The no-ff merge path uses
update-refto advance the target branch, then syncs the target worktree. Previously this usedreset --hard HEAD, which would silently discard any tracked-file modifications added between the pre-push dirty check and the sync.reset --keepwould be the natural safe alternative, but it can't be used here: afterupdate-ref, HEAD already points to the merge commit, soreset --keep HEADsees old==new and is a no-op.read-tree -m -u <old_tip> <merge_sha>performs a two-tree merge that correctly updates the index and working tree, and refuses if any tracked files have local modifications — exactly the TOCTOU safety behavior we want.Audit results: This was the only
reset --hardin production code (src/). The remaining uses intests/are for deliberate test state setup (behind/diverged scenarios) and are appropriate.Test plan
test_merge_no_ff*tests passtest_push*tests pass🤖 Generated with Claude Code