]>
Commit | Line | Data |
---|---|---|
d22eb044 SB |
1 | #!/bin/sh |
2 | ||
3 | test_description='Test shallow cloning of repos with submodules' | |
4 | ||
5 | . ./test-lib.sh | |
6 | ||
7 | pwd=$(pwd) | |
8 | ||
9 | test_expect_success 'setup' ' | |
10 | git checkout -b master && | |
11 | test_commit commit1 && | |
12 | test_commit commit2 && | |
13 | mkdir sub && | |
14 | ( | |
15 | cd sub && | |
16 | git init && | |
17 | test_commit subcommit1 && | |
18 | test_commit subcommit2 && | |
19 | test_commit subcommit3 | |
20 | ) && | |
21 | git submodule add "file://$pwd/sub" sub && | |
22 | git commit -m "add submodule" | |
23 | ' | |
24 | ||
25 | test_expect_success 'nonshallow clone implies nonshallow submodule' ' | |
26 | test_when_finished "rm -rf super_clone" && | |
27 | git clone --recurse-submodules "file://$pwd/." super_clone && | |
5819c2ee SB |
28 | git -C super_clone log --oneline >lines && |
29 | test_line_count = 3 lines && | |
30 | git -C super_clone/sub log --oneline >lines && | |
31 | test_line_count = 3 lines | |
d22eb044 SB |
32 | ' |
33 | ||
18a74a09 | 34 | test_expect_success 'shallow clone with shallow submodule' ' |
d22eb044 | 35 | test_when_finished "rm -rf super_clone" && |
18a74a09 | 36 | git clone --recurse-submodules --depth 2 --shallow-submodules "file://$pwd/." super_clone && |
5819c2ee SB |
37 | git -C super_clone log --oneline >lines && |
38 | test_line_count = 2 lines && | |
39 | git -C super_clone/sub log --oneline >lines && | |
40 | test_line_count = 1 lines | |
d22eb044 SB |
41 | ' |
42 | ||
18a74a09 JH |
43 | test_expect_success 'shallow clone does not imply shallow submodule' ' |
44 | test_when_finished "rm -rf super_clone" && | |
45 | git clone --recurse-submodules --depth 2 "file://$pwd/." super_clone && | |
5819c2ee SB |
46 | git -C super_clone log --oneline >lines && |
47 | test_line_count = 2 lines && | |
48 | git -C super_clone/sub log --oneline >lines && | |
49 | test_line_count = 3 lines | |
18a74a09 JH |
50 | ' |
51 | ||
d22eb044 SB |
52 | test_expect_success 'shallow clone with non shallow submodule' ' |
53 | test_when_finished "rm -rf super_clone" && | |
54 | git clone --recurse-submodules --depth 2 --no-shallow-submodules "file://$pwd/." super_clone && | |
5819c2ee SB |
55 | git -C super_clone log --oneline >lines && |
56 | test_line_count = 2 lines && | |
57 | git -C super_clone/sub log --oneline >lines && | |
58 | test_line_count = 3 lines | |
d22eb044 SB |
59 | ' |
60 | ||
61 | test_expect_success 'non shallow clone with shallow submodule' ' | |
62 | test_when_finished "rm -rf super_clone" && | |
63 | git clone --recurse-submodules --no-local --shallow-submodules "file://$pwd/." super_clone && | |
5819c2ee SB |
64 | git -C super_clone log --oneline >lines && |
65 | test_line_count = 3 lines && | |
66 | git -C super_clone/sub log --oneline >lines && | |
67 | test_line_count = 1 lines | |
d22eb044 SB |
68 | ' |
69 | ||
abed000a SB |
70 | test_expect_success 'clone follows shallow recommendation' ' |
71 | test_when_finished "rm -rf super_clone" && | |
72 | git config -f .gitmodules submodule.sub.shallow true && | |
73 | git add .gitmodules && | |
64127575 | 74 | git commit -m "recommend shallow for sub" && |
abed000a SB |
75 | git clone --recurse-submodules --no-local "file://$pwd/." super_clone && |
76 | ( | |
77 | cd super_clone && | |
78 | git log --oneline >lines && | |
79 | test_line_count = 4 lines | |
80 | ) && | |
81 | ( | |
82 | cd super_clone/sub && | |
83 | git log --oneline >lines && | |
84 | test_line_count = 1 lines | |
85 | ) | |
86 | ' | |
87 | ||
88 | test_expect_success 'get unshallow recommended shallow submodule' ' | |
89 | test_when_finished "rm -rf super_clone" && | |
90 | git clone --no-local "file://$pwd/." super_clone && | |
91 | ( | |
92 | cd super_clone && | |
93 | git submodule update --init --no-recommend-shallow && | |
94 | git log --oneline >lines && | |
95 | test_line_count = 4 lines | |
96 | ) && | |
97 | ( | |
98 | cd super_clone/sub && | |
99 | git log --oneline >lines && | |
100 | test_line_count = 3 lines | |
101 | ) | |
102 | ' | |
103 | ||
104 | test_expect_success 'clone follows non shallow recommendation' ' | |
105 | test_when_finished "rm -rf super_clone" && | |
106 | git config -f .gitmodules submodule.sub.shallow false && | |
107 | git add .gitmodules && | |
64127575 | 108 | git commit -m "recommend non shallow for sub" && |
abed000a SB |
109 | git clone --recurse-submodules --no-local "file://$pwd/." super_clone && |
110 | ( | |
111 | cd super_clone && | |
112 | git log --oneline >lines && | |
113 | test_line_count = 5 lines | |
114 | ) && | |
115 | ( | |
116 | cd super_clone/sub && | |
117 | git log --oneline >lines && | |
118 | test_line_count = 3 lines | |
119 | ) | |
120 | ' | |
121 | ||
d22eb044 | 122 | test_done |