@@ -512,6 +512,56 @@ test_expect_success 'push only unpushed submodules recursively' '
512512 test_cmp expected_pub actual_pub
513513'
514514
515+ setup_subsub () {
516+ git init upstream &&
517+ git init upstream/sub &&
518+ git init upstream/sub/deepsub &&
519+ test_commit -C upstream/sub/deepsub innermost &&
520+ git -C upstream/sub submodule add ./deepsub deepsub &&
521+ git -C upstream/sub commit -m middle &&
522+ git -C upstream submodule add ./sub sub &&
523+ git -C upstream commit -m outermost &&
524+
525+ git -c protocol.file.allow=always clone --recurse-submodules upstream downstream &&
526+ git -C downstream/sub/deepsub checkout -b downstream-branch &&
527+ git -C downstream/sub checkout -b downstream-branch &&
528+ git -C downstream checkout -b downstream-branch
529+ }
530+
531+ new_downstream_commits () {
532+ test_commit -C downstream/sub/deepsub new-innermost &&
533+ git -C downstream/sub add deepsub &&
534+ git -C downstream/sub commit -m new-middle &&
535+ git -C downstream add sub &&
536+ git -C downstream commit -m new-outermost
537+ }
538+
539+ test_expect_success ' push with push.recurseSubmodules=only on superproject' '
540+ test_when_finished rm -rf upstream downstream &&
541+ setup_subsub &&
542+ new_downstream_commits &&
543+ git -C downstream config push.recurseSubmodules only &&
544+ git -C downstream push origin downstream-branch &&
545+
546+ test_must_fail git -C upstream rev-parse refs/heads/downstream-branch &&
547+ git -C upstream/sub rev-parse refs/heads/downstream-branch &&
548+ test_must_fail git -C upstream/sub/deepsub rev-parse refs/heads/downstream-branch
549+ '
550+
551+ test_expect_success ' push with push.recurseSubmodules=only on superproject and top-level submodule' '
552+ test_when_finished rm -rf upstream downstream &&
553+ setup_subsub &&
554+ new_downstream_commits &&
555+ git -C downstream config push.recurseSubmodules only &&
556+ git -C downstream/sub config push.recurseSubmodules only &&
557+ git -C downstream push origin downstream-branch 2> err &&
558+
559+ test_must_fail git -C upstream rev-parse refs/heads/downstream-branch &&
560+ git -C upstream/sub rev-parse refs/heads/downstream-branch &&
561+ git -C upstream/sub/deepsub rev-parse refs/heads/downstream-branch &&
562+ grep "recursing into submodule with push.recurseSubmodules=only; using on-demand instead" err
563+ '
564+
515565test_expect_success ' push propagating the remotes name to a submodule' '
516566 git -C work remote add origin ../pub.git &&
517567 git -C work remote add pub ../pub.git &&
0 commit comments