Repository navigation
fix: disable submodule recursion in local push and reset - #1619
Conversation
| { | ||
| let target_wt = ctx.repo.worktree_at(wt_path); | ||
| if let Err(e) = target_wt.run_command(&["reset", "--hard", "HEAD"]) { | ||
| let reset_args = ["-c", "submodule.recurse=false", "reset", "--hard", "HEAD"]; |
There was a problem hiding this comment.
separately from this change, can we add some comments around reset --hard? I worry when I see that, and I think this was contributed code. Why do we need to be doing this? Can we do something less aggressive. we want to favor retaining data and failing if there is a race condition, such as a file being added and we get a TOUTOC race
There was a problem hiding this comment.
Good call — reset --hard here is more aggressive than necessary. This was added in #1438 to sync the target worktree's working tree after the ref is updated via update-ref (plumbing-based merge). The ref already points to the merge commit, so the working tree just needs to catch up.
reset --keep is a direct replacement that's safer: it updates the working tree to match HEAD but refuses if any tracked file has local modifications, which handles the TOCTOU race you're describing. (Untracked files are preserved by both --hard and --keep.)
I'll switch to --keep and add a comment explaining why it's there and why --keep over --hard. Will push shortly.
There was a problem hiding this comment.
excellent! and can you do an audit of any other uses of anything similar in the repo, post any changes in a new PR? and add guidance to CLAUDE.md in the relevant place that we should always "favor retaining data and failing if there is a race condition", to the extent that's not there already?
There was a problem hiding this comment.
On it — I'll audit the repo for reset --hard and similar aggressive operations, switch any that can safely use --keep instead, and add guidance to CLAUDE.md. Will post a separate PR.
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]>
|
@worktrunk-bot resoove conflicts |
When users have `submodule.recurse=true` in their git config, `wt merge` fails because `git push` tries to recurse into submodules during what is a local worktree-to-worktree ref update. Add `--recurse-submodules=no` to the push command and `-c submodule.recurse=false` to the reset in the no-ff path, since submodule recursion is irrelevant for these operations. Closes #1604 Co-Authored-By: Claude Opus 4.6 <[email protected]>
845c040 to
4a4fbba
Compare
|
Rebased onto main and resolved the conflict with #1623. The |
Summary
--recurse-submodules=noto the localgit pushinwt merge/wt step pushto preventsubmodule.recurse=truefrom interfering with worktree-to-worktree ref updatessubmodule.recurse=trueconfigThe
reset --hardfix from the original PR is no longer needed — #1623 replacedreset --hardwithread-tree -m -u, which doesn't recurse into submodules.Closes #1604
Test plan
test_push_with_submodule_recurse_config— verifies fast-forward push succeeds withsubmodule.recurse=truetest_push_no_ff_with_submodule_recurse_config— verifies no-ff push succeeds withsubmodule.recurse=true🤖 Generated with Claude Code