worktrunk icon indicating copy to clipboard operation
worktrunk copied to clipboard

`wt merge` fails with submodule push error

Open viicslen opened this issue 8 months ago • 3 comments

Bug Report

Description

wt merge fails when the repository contains git submodules.

Steps to Reproduce

  1. Have a repo with git submodules
  2. Create a worktree and make changes in the worktree
  3. Run wt merge <branch>

Error

✗ Can't push to local <branch> branch
  The following submodule paths contain changes that can
  not be found on any remote:
    modules/<submodule-name>
  Please try
  git push --recurse-submodules=on-demand
  fatal: Aborting.
  fatal: the remote end hung up unexpectedly

Expected Behavior

wt merge should succeed. The submodule has no new commits and no local changes (git status is clean, git log --oneline origin/HEAD..HEAD returns nothing).

Environment

  • worktrunk version: wt 0f0cb2a
  • git version: git version 2.52.0
  • OS: nixos

viicslen avatar Mar 18 '26 16:03 viicslen

Thanks for reporting this! I investigated the git push command that wt merge uses internally (in src/commands/worktree/push.rs):

ctx.repo.run_command(&[
    "push",
    "--receive-pack=git -c receive.denyCurrentBranch=updateInstead receive-pack",
    git_common_dir_str.as_ref(),
    &push_target,
])

This push targets the local .git directory (not a remote), but it doesn't pass --recurse-submodules=no, so git's push.recurseSubmodules config can interfere. The likely fix is adding --recurse-submodules=no to this push command, since submodule recursion is irrelevant for a local worktree-to-worktree ref update.

I wasn't able to reproduce the failure on git 2.53.0 / Linux — even with push.recurseSubmodules=check and on-demand explicitly set, the local push succeeds. Could you share a bit more about your setup?

  • What's your push.recurseSubmodules setting? (git config --get push.recurseSubmodules at both repo and global level)
  • Is the submodule using an SSH or HTTPS URL?
  • Any relevant .gitconfig settings related to submodules?

That would help reproduce and validate a fix. A maintainer will also take a look.

worktrunk-bot avatar Mar 18 '26 16:03 worktrunk-bot

Upon further inspection, unsetting submodule.recurse=true in the .gitconfig has fixed this issue for me however this might be something worktrunk might want to handle on its own so that the user doesnt have to change their git configs

viicslen avatar Mar 19 '26 14:03 viicslen

Thanks for confirming! That makes sense — submodule.recurse=true causes git push to try recursing into submodules, which fails for the local worktree-to-worktree push that wt merge uses internally.

I've opened #1619 to fix this. It adds --recurse-submodules=no to the local push command and also protects the git reset --hard in the --no-ff path with -c submodule.recurse=false. Submodule recursion is irrelevant for both operations since they're purely local ref updates.

worktrunk-bot avatar Mar 19 '26 14:03 worktrunk-bot