Skip to content

fix: disable submodule recursion in local push and reset - #1619

Merged
max-sixty merged 1 commit into
mainfrom
fix/submodule-recurse-push
Mar 19, 2026
Merged

max-sixty merged 1 commit into
mainfrom
fix/submodule-recurse-push

Conversation

@worktrunk-bot

@worktrunk-bot worktrunk-bot commented Mar 19, 2026 •

Copy link
Copy Markdown
Collaborator

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

  • New test test_push_with_submodule_recurse_config — verifies fast-forward push succeeds with submodule.recurse=true
  • New test test_push_no_ff_with_submodule_recurse_config — verifies no-ff push succeeds with submodule.recurse=true
  • All existing push tests still pass
  • Lints pass

🤖 Generated with Claude Code

Comment thread src/commands/worktree/push.rs Outdated
{
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"];

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

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]>
@max-sixty

Copy link
Copy Markdown
Owner

@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]>
@worktrunk-bot
worktrunk-bot force-pushed the fix/submodule-recurse-push branch from 845c040 to 4a4fbba Compare March 19, 2026 20:06
@worktrunk-bot

Copy link
Copy Markdown
Collaborator Author

Rebased onto main and resolved the conflict with #1623. The reset --hard fix was dropped since read-tree -m -u doesn't recurse into submodules — only the --recurse-submodules=no on git push remains. Both submodule regression tests pass.

@max-sixty
max-sixty merged commit 344082f into main Mar 19, 2026
22 checks passed
@max-sixty
max-sixty deleted the fix/submodule-recurse-push branch March 19, 2026 20:38
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.

wt merge fails with submodule push error

2 participants