refs/files: skip creation of "refs/{heads,tags}" for worktrees
[git.git] / t / t5614-clone-submodules-shallow.sh
blobc2a2bb453eeabcc8725bffae2c537ec99b8a7d87
1 #!/bin/sh
3 test_description='Test shallow cloning of repos with submodules'
5 TEST_PASSES_SANITIZE_LEAK=true
6 . ./test-lib.sh
8 pwd=$(pwd)
10 test_expect_success 'setup' '
11 git checkout -b main &&
12 test_commit commit1 &&
13 test_commit commit2 &&
14 mkdir sub &&
16 cd sub &&
17 git init &&
18 test_commit subcommit1 &&
19 test_commit subcommit2 &&
20 test_commit subcommit3
21 ) &&
22 git submodule add "file://$pwd/sub" sub &&
23 git commit -m "add submodule"
26 test_expect_success 'nonshallow clone implies nonshallow submodule' '
27 test_when_finished "rm -rf super_clone" &&
28 test_config_global protocol.file.allow always &&
29 git clone --recurse-submodules "file://$pwd/." super_clone &&
30 git -C super_clone log --oneline >lines &&
31 test_line_count = 3 lines &&
32 git -C super_clone/sub log --oneline >lines &&
33 test_line_count = 3 lines
36 test_expect_success 'shallow clone with shallow submodule' '
37 test_when_finished "rm -rf super_clone" &&
38 test_config_global protocol.file.allow always &&
39 git clone --recurse-submodules --depth 2 --shallow-submodules "file://$pwd/." super_clone &&
40 git -C super_clone log --oneline >lines &&
41 test_line_count = 2 lines &&
42 git -C super_clone/sub log --oneline >lines &&
43 test_line_count = 1 lines
46 test_expect_success 'shallow clone does not imply shallow submodule' '
47 test_when_finished "rm -rf super_clone" &&
48 test_config_global protocol.file.allow always &&
49 git clone --recurse-submodules --depth 2 "file://$pwd/." super_clone &&
50 git -C super_clone log --oneline >lines &&
51 test_line_count = 2 lines &&
52 git -C super_clone/sub log --oneline >lines &&
53 test_line_count = 3 lines
56 test_expect_success 'shallow clone with non shallow submodule' '
57 test_when_finished "rm -rf super_clone" &&
58 test_config_global protocol.file.allow always &&
59 git clone --recurse-submodules --depth 2 --no-shallow-submodules "file://$pwd/." super_clone &&
60 git -C super_clone log --oneline >lines &&
61 test_line_count = 2 lines &&
62 git -C super_clone/sub log --oneline >lines &&
63 test_line_count = 3 lines
66 test_expect_success 'non shallow clone with shallow submodule' '
67 test_when_finished "rm -rf super_clone" &&
68 test_config_global protocol.file.allow always &&
69 git clone --recurse-submodules --no-local --shallow-submodules "file://$pwd/." super_clone &&
70 git -C super_clone log --oneline >lines &&
71 test_line_count = 3 lines &&
72 git -C super_clone/sub log --oneline >lines &&
73 test_line_count = 1 lines
76 test_expect_success 'clone follows shallow recommendation' '
77 test_when_finished "rm -rf super_clone" &&
78 test_config_global protocol.file.allow always &&
79 git config -f .gitmodules submodule.sub.shallow true &&
80 git add .gitmodules &&
81 git commit -m "recommend shallow for sub" &&
82 git clone --recurse-submodules --no-local "file://$pwd/." super_clone &&
84 cd super_clone &&
85 git log --oneline >lines &&
86 test_line_count = 4 lines
87 ) &&
89 cd super_clone/sub &&
90 git log --oneline >lines &&
91 test_line_count = 1 lines
95 test_expect_success 'get unshallow recommended shallow submodule' '
96 test_when_finished "rm -rf super_clone" &&
97 test_config_global protocol.file.allow always &&
98 git clone --no-local "file://$pwd/." super_clone &&
100 cd super_clone &&
101 git submodule update --init --no-recommend-shallow &&
102 git log --oneline >lines &&
103 test_line_count = 4 lines
104 ) &&
106 cd super_clone/sub &&
107 git log --oneline >lines &&
108 test_line_count = 3 lines
112 test_expect_success 'clone follows non shallow recommendation' '
113 test_when_finished "rm -rf super_clone" &&
114 test_config_global protocol.file.allow always &&
115 git config -f .gitmodules submodule.sub.shallow false &&
116 git add .gitmodules &&
117 git commit -m "recommend non shallow for sub" &&
118 git clone --recurse-submodules --no-local "file://$pwd/." super_clone &&
120 cd super_clone &&
121 git log --oneline >lines &&
122 test_line_count = 5 lines
123 ) &&
125 cd super_clone/sub &&
126 git log --oneline >lines &&
127 test_line_count = 3 lines
131 test_done