fsck: warn about symlink pointing inside a gitdir
[git.git] / t / t5617-clone-submodules-remote.sh
blob688433824934d89354669d920acd1fb06a5da725
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 # bare clone giving "srv.bare" for use as our server.
33 test_expect_success 'setup bare clone for server' '
34 git clone --bare "file://$(pwd)/." srv.bare &&
35 git -C srv.bare config --local uploadpack.allowfilter 1 &&
36 git -C srv.bare config --local uploadpack.allowanysha1inwant 1
39 test_expect_success 'clone with --no-remote-submodules' '
40 test_when_finished "rm -rf super_clone" &&
41 git clone --recurse-submodules --no-remote-submodules "file://$pwd/." super_clone &&
43 cd super_clone/sub &&
44 git diff --exit-code sub_when_added_to_super
48 test_expect_success 'clone with --remote-submodules' '
49 test_when_finished "rm -rf super_clone" &&
50 git clone --recurse-submodules --remote-submodules "file://$pwd/." super_clone &&
52 cd super_clone/sub &&
53 git diff --exit-code remotes/origin/main
57 test_expect_success 'check the default is --no-remote-submodules' '
58 test_when_finished "rm -rf super_clone" &&
59 git clone --recurse-submodules "file://$pwd/." super_clone &&
61 cd super_clone/sub &&
62 git diff --exit-code sub_when_added_to_super
66 test_expect_success 'clone with --single-branch' '
67 test_when_finished "rm -rf super_clone" &&
68 git clone --recurse-submodules --single-branch "file://$pwd/." super_clone &&
70 cd super_clone/sub &&
71 git rev-parse --verify origin/main &&
72 test_must_fail git rev-parse --verify origin/other
76 # do basic partial clone from "srv.bare"
77 # confirm partial clone was registered in the local config for super and sub.
78 test_expect_success 'clone with --filter' '
79 git clone --recurse-submodules \
80 --filter blob:none --also-filter-submodules \
81 "file://$pwd/srv.bare" super_clone &&
82 test_cmp_config -C super_clone true remote.origin.promisor &&
83 test_cmp_config -C super_clone blob:none remote.origin.partialclonefilter &&
84 test_cmp_config -C super_clone/sub true remote.origin.promisor &&
85 test_cmp_config -C super_clone/sub blob:none remote.origin.partialclonefilter
88 # check that clone.filterSubmodules works (--also-filter-submodules can be
89 # omitted)
90 test_expect_success 'filters applied with clone.filterSubmodules' '
91 test_config_global clone.filterSubmodules true &&
92 git clone --recurse-submodules --filter blob:none \
93 "file://$pwd/srv.bare" super_clone2 &&
94 test_cmp_config -C super_clone2 true remote.origin.promisor &&
95 test_cmp_config -C super_clone2 blob:none remote.origin.partialclonefilter &&
96 test_cmp_config -C super_clone2/sub true remote.origin.promisor &&
97 test_cmp_config -C super_clone2/sub blob:none remote.origin.partialclonefilter
100 test_expect_success '--no-also-filter-submodules overrides clone.filterSubmodules=true' '
101 test_config_global clone.filterSubmodules true &&
102 git clone --recurse-submodules --filter blob:none \
103 --no-also-filter-submodules \
104 "file://$pwd/srv.bare" super_clone3 &&
105 test_cmp_config -C super_clone3 true remote.origin.promisor &&
106 test_cmp_config -C super_clone3 blob:none remote.origin.partialclonefilter &&
107 test_cmp_config -C super_clone3/sub false --default false remote.origin.promisor
110 test_done