Skip to content

Worktrunk is a CLI for Git worktree management, designed for parallel AI agent workflows

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

worktrunk-bot344082f102b4
diff --git a/src/commands/worktree/push.rs b/src/commands/worktree/push.rs
index fb5c935d6..bd809aa15 100644
--- a/src/commands/worktree/push.rs
+++ b/src/commands/worktree/push.rs
@@ -268,6 +268,7 @@ pub fn handle_push(
ctx.repo
.run_command(&[
"push",
+ "--recurse-submodules=no",
"--receive-pack=git -c receive.denyCurrentBranch=updateInstead receive-pack",
git_common_dir_str.as_ref(),
&push_target,
diff --git a/tests/integration_tests/push.rs b/tests/integration_tests/push.rs
index 4d8ff40ec..84dc864ef 100644
--- a/tests/integration_tests/push.rs
+++ b/tests/integration_tests/push.rs
@@ -255,6 +255,46 @@ fn test_push_no_ff(mut repo: TestRepo) {
assert_eq!(commit_msg, "Merge branch 'feature' into main");
}
+#[rstest]
+fn test_push_with_submodule_recurse_config(mut repo: TestRepo) {
+ // Regression test for https://github.com/max-sixty/worktrunk/issues/1604
+ // When submodule.recurse=true is set, git push tries to recurse into
+ // submodules which fails for local worktree-to-worktree pushes.
+ repo.run_git(&["config", "submodule.recurse", "true"]);
+
+ repo.add_main_worktree();
+
+ let feature_wt =
+ repo.add_worktree_with_commit("feature", "test.txt", "test content", "Add test file");
+
+ // Fast-forward push should succeed despite submodule.recurse=true
+ snapshot_push(
+ "push_with_submodule_recurse",
+ &repo,
+ &["main"],
+ Some(&feature_wt),
+ );
+}
+
+#[rstest]
+fn test_push_no_ff_with_submodule_recurse_config(mut repo: TestRepo) {
+ // Regression test for https://github.com/max-sixty/worktrunk/issues/1604
+ repo.run_git(&["config", "submodule.recurse", "true"]);
+
+ repo.add_main_worktree();
+
+ let feature_wt =
+ repo.add_worktree_with_commit("feature", "test.txt", "test content", "Add test file");
+
+ // No-ff push should succeed despite submodule.recurse=true
+ snapshot_push(
+ "push_no_ff_with_submodule_recurse",
+ &repo,
+ &["--no-ff", "main"],
+ Some(&feature_wt),
+ );
+}
+
#[rstest]
fn test_push_no_remote(#[from(repo_with_feature_worktree)] repo: TestRepo) {
// Note: repo_with_feature_worktree doesn't call setup_remote(), so this tests the "no remote" error case
diff --git a/tests/snapshots/integration__integration_tests__push__push_no_ff_with_submodule_recurse.snap b/tests/snapshots/integration__integration_tests__push__push_no_ff_with_submodule_recurse.snap
new file mode 100644
index 000000000..1cc648982
--- /dev/null
+++ b/tests/snapshots/integration__integration_tests__push__push_no_ff_with_submodule_recurse.snap
@@ -0,0 +1,51 @@
+---
+source: tests/integration_tests/push.rs
+info:
+ program: wt
+ args:
+ - step
+ - push
+ - "--no-ff"
+ - main
+ env:
+ APPDATA: "[TEST_CONFIG_HOME]"
+ CLICOLOR_FORCE: "1"
+ COLUMNS: "500"
+ GIT_AUTHOR_DATE: "2025-01-01T00:00:00Z"
+ GIT_COMMITTER_DATE: "2025-01-01T00:00:00Z"
+ GIT_CONFIG_GLOBAL: "[TEST_GIT_CONFIG]"
+ GIT_CONFIG_SYSTEM: /dev/null
+ GIT_EDITOR: ""
+ GIT_TERMINAL_PROMPT: "0"
+ HOME: "[TEST_HOME]"
+ LANG: C
+ LC_ALL: C
+ MOCK_CONFIG_DIR: "[MOCK_CONFIG_DIR]"
+ NO_COLOR: ""
+ PATH: "[PATH]"
+ PSModulePath: ""
+ RUST_LOG: warn
+ SHELL: ""
+ TERM: alacritty
+ USERPROFILE: "[TEST_HOME]"
+ WORKTRUNK_APPROVALS_PATH: "[TEST_APPROVALS]"
+ WORKTRUNK_CONFIG_PATH: "[TEST_CONFIG]"
+ WORKTRUNK_SYSTEM_CONFIG_PATH: "[TEST_SYSTEM_CONFIG]"
+ WORKTRUNK_TEST_CLAUDE_INSTALLED: "0"
+ WORKTRUNK_TEST_DELAYED_STREAM_MS: "-1"
+ WORKTRUNK_TEST_EPOCH: "1735776000"
+ WORKTRUNK_TEST_NUSHELL_ENV: "0"
+ WORKTRUNK_TEST_POWERSHELL_ENV: "0"
+ WORKTRUNK_TEST_SKIP_URL_HEALTH_CHECK: "1"
+ XDG_CONFIG_HOME: "[TEST_CONFIG_HOME]"
+---
+success: true
+exit_code: 0
+----- stdout -----
+
+----- stderr -----
+◎ Merging 1 commit to main @ [HASH] (--no-ff)
+  * [HASH] Add test file
+  test.txt | 1 +
+  1 file changed, 1 insertion(+)
+✓ Merged to main @ [HASH] (1 commit, 1 file, +1, --no-ff)
diff --git a/tests/snapshots/integration__integration_tests__push__push_with_submodule_recurse.snap b/tests/snapshots/integration__integration_tests__push__push_with_submodule_recurse.snap
new file mode 100644
index 000000000..bc6512c00
--- /dev/null
+++ b/tests/snapshots/integration__integration_tests__push__push_with_submodule_recurse.snap
@@ -0,0 +1,50 @@
+---
+source: tests/integration_tests/push.rs
+info:
+ program: wt
+ args:
+ - step
+ - push
+ - main
+ env:
+ APPDATA: "[TEST_CONFIG_HOME]"
+ CLICOLOR_FORCE: "1"
+ COLUMNS: "500"
+ GIT_AUTHOR_DATE: "2025-01-01T00:00:00Z"
+ GIT_COMMITTER_DATE: "2025-01-01T00:00:00Z"
+ GIT_CONFIG_GLOBAL: "[TEST_GIT_CONFIG]"
+ GIT_CONFIG_SYSTEM: /dev/null
+ GIT_EDITOR: ""
+ GIT_TERMINAL_PROMPT: "0"
+ HOME: "[TEST_HOME]"
+ LANG: C
+ LC_ALL: C
+ MOCK_CONFIG_DIR: "[MOCK_CONFIG_DIR]"
+ NO_COLOR: ""
+ PATH: "[PATH]"
+ PSModulePath: ""
+ RUST_LOG: warn
+ SHELL: ""
+ TERM: alacritty
+ USERPROFILE: "[TEST_HOME]"
+ WORKTRUNK_APPROVALS_PATH: "[TEST_APPROVALS]"
+ WORKTRUNK_CONFIG_PATH: "[TEST_CONFIG]"
+ WORKTRUNK_SYSTEM_CONFIG_PATH: "[TEST_SYSTEM_CONFIG]"
+ WORKTRUNK_TEST_CLAUDE_INSTALLED: "0"
+ WORKTRUNK_TEST_DELAYED_STREAM_MS: "-1"
+ WORKTRUNK_TEST_EPOCH: "1735776000"
+ WORKTRUNK_TEST_NUSHELL_ENV: "0"
+ WORKTRUNK_TEST_POWERSHELL_ENV: "0"
+ WORKTRUNK_TEST_SKIP_URL_HEALTH_CHECK: "1"
+ XDG_CONFIG_HOME: "[TEST_CONFIG_HOME]"
+---
+success: true
+exit_code: 0
+----- stdout -----
+
+----- stderr -----
+◎ Pushing 1 commit to main @ [HASH]
+  * [HASH] Add test file
+  test.txt | 1 +
+  1 file changed, 1 insertion(+)
+✓ Pushed to main (1 commit, 1 file, +1)