Git 2.33.8
[git.git] / t / t5617-clone-submodules-remote.sh
blob5691f27405c060293ea400b551e86dc21e7aee91
1 #!/bin/sh
3 test_description='Test cloning repos with submodules using remote-tracking branches'
5 GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
6 export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
8 . ./test-lib.sh
10 pwd=$(pwd)
12 test_expect_success 'setup' '
13 git config --global protocol.file.allow always &&
14 git checkout -b main &&
15 test_commit commit1 &&
16 mkdir sub &&
18 cd sub &&
19 git init &&
20 test_commit subcommit1 &&
21 git tag sub_when_added_to_super &&
22 git branch other
23 ) &&
24 git submodule add "file://$pwd/sub" sub &&
25 git commit -m "add submodule" &&
27 cd sub &&
28 test_commit subcommit2
32 test_expect_success 'clone with --no-remote-submodules' '
33 test_when_finished "rm -rf super_clone" &&
34 git clone --recurse-submodules --no-remote-submodules "file://$pwd/." super_clone &&
36 cd super_clone/sub &&
37 git diff --exit-code sub_when_added_to_super
41 test_expect_success 'clone with --remote-submodules' '
42 test_when_finished "rm -rf super_clone" &&
43 git clone --recurse-submodules --remote-submodules "file://$pwd/." super_clone &&
45 cd super_clone/sub &&
46 git diff --exit-code remotes/origin/main
50 test_expect_success 'check the default is --no-remote-submodules' '
51 test_when_finished "rm -rf super_clone" &&
52 git clone --recurse-submodules "file://$pwd/." super_clone &&
54 cd super_clone/sub &&
55 git diff --exit-code sub_when_added_to_super
59 test_expect_success 'clone with --single-branch' '
60 test_when_finished "rm -rf super_clone" &&
61 git clone --recurse-submodules --single-branch "file://$pwd/." super_clone &&
63 cd super_clone/sub &&
64 git rev-parse --verify origin/main &&
65 test_must_fail git rev-parse --verify origin/other
69 test_done