]> git.ipfire.org Git - thirdparty/git.git/blob - t/t9211-scalar-clone.sh
The third batch
[thirdparty/git.git] / t / t9211-scalar-clone.sh
1 #!/bin/sh
2
3 test_description='test the `scalar clone` subcommand'
4
5 . ./test-lib.sh
6 . "${TEST_DIRECTORY}/lib-terminal.sh"
7
8 GIT_TEST_MAINT_SCHEDULER="crontab:test-tool crontab cron.txt,launchctl:true,schtasks:true"
9 export GIT_TEST_MAINT_SCHEDULER
10
11 test_expect_success 'set up repository to clone' '
12 rm -rf .git &&
13 git init to-clone &&
14 (
15 cd to-clone &&
16 git branch -m base &&
17
18 test_commit first &&
19 test_commit second &&
20 test_commit third &&
21
22 git switch -c parallel first &&
23 mkdir -p 1/2 &&
24 test_commit 1/2/3 &&
25
26 git switch base &&
27
28 # By default, permit
29 git config uploadpack.allowfilter true &&
30 git config uploadpack.allowanysha1inwant true
31 )
32 '
33
34 cleanup_clone () {
35 rm -rf "$1"
36 }
37
38 test_expect_success 'creates content in enlistment root' '
39 enlistment=cloned &&
40
41 scalar clone "file://$(pwd)/to-clone" $enlistment &&
42 ls -A $enlistment >enlistment-root &&
43 test_line_count = 1 enlistment-root &&
44 test_path_is_dir $enlistment/src &&
45 test_path_is_dir $enlistment/src/.git &&
46
47 cleanup_clone $enlistment
48 '
49
50 test_expect_success 'with spaces' '
51 enlistment="cloned with space" &&
52
53 scalar clone "file://$(pwd)/to-clone" "$enlistment" &&
54 test_path_is_dir "$enlistment" &&
55 test_path_is_dir "$enlistment/src" &&
56 test_path_is_dir "$enlistment/src/.git" &&
57
58 cleanup_clone "$enlistment"
59 '
60
61 test_expect_success 'partial clone if supported by server' '
62 enlistment=partial-clone &&
63
64 scalar clone "file://$(pwd)/to-clone" $enlistment &&
65
66 (
67 cd $enlistment/src &&
68
69 # Two promisor packs: one for refs, the other for blobs
70 ls .git/objects/pack/pack-*.promisor >promisorlist &&
71 test_line_count = 2 promisorlist
72 ) &&
73
74 cleanup_clone $enlistment
75 '
76
77 test_expect_success 'fall back on full clone if partial unsupported' '
78 enlistment=no-partial-support &&
79
80 test_config -C to-clone uploadpack.allowfilter false &&
81 test_config -C to-clone uploadpack.allowanysha1inwant false &&
82
83 scalar clone "file://$(pwd)/to-clone" $enlistment 2>err &&
84 grep "filtering not recognized by server, ignoring" err &&
85
86 (
87 cd $enlistment/src &&
88
89 # Still get a refs promisor file, but none for blobs
90 ls .git/objects/pack/pack-*.promisor >promisorlist &&
91 test_line_count = 1 promisorlist
92 ) &&
93
94 cleanup_clone $enlistment
95 '
96
97 test_expect_success 'initializes sparse-checkout by default' '
98 enlistment=sparse &&
99
100 scalar clone "file://$(pwd)/to-clone" $enlistment &&
101 (
102 cd $enlistment/src &&
103 test_cmp_config true core.sparseCheckout &&
104 test_cmp_config true core.sparseCheckoutCone
105 ) &&
106
107 cleanup_clone $enlistment
108 '
109
110 test_expect_success '--full-clone does not create sparse-checkout' '
111 enlistment=full-clone &&
112
113 scalar clone --full-clone "file://$(pwd)/to-clone" $enlistment &&
114 (
115 cd $enlistment/src &&
116 test_cmp_config "" --default "" core.sparseCheckout &&
117 test_cmp_config "" --default "" core.sparseCheckoutCone
118 ) &&
119
120 cleanup_clone $enlistment
121 '
122
123 test_expect_success '--single-branch clones HEAD only' '
124 enlistment=single-branch &&
125
126 scalar clone --single-branch "file://$(pwd)/to-clone" $enlistment &&
127 (
128 cd $enlistment/src &&
129 git for-each-ref refs/remotes/origin >out &&
130 test_line_count = 1 out &&
131 grep "refs/remotes/origin/base" out
132 ) &&
133
134 cleanup_clone $enlistment
135 '
136
137 test_expect_success '--no-single-branch clones all branches' '
138 enlistment=no-single-branch &&
139
140 scalar clone --no-single-branch "file://$(pwd)/to-clone" $enlistment &&
141 (
142 cd $enlistment/src &&
143 git for-each-ref refs/remotes/origin >out &&
144 test_line_count = 2 out &&
145 grep "refs/remotes/origin/base" out &&
146 grep "refs/remotes/origin/parallel" out
147 ) &&
148
149 cleanup_clone $enlistment
150 '
151
152 test_expect_success TTY 'progress with tty' '
153 enlistment=progress1 &&
154
155 test_config -C to-clone uploadpack.allowfilter true &&
156 test_config -C to-clone uploadpack.allowanysha1inwant true &&
157
158 test_terminal env GIT_PROGRESS_DELAY=0 \
159 scalar clone "file://$(pwd)/to-clone" "$enlistment" 2>stderr &&
160 grep "Enumerating objects" stderr >actual &&
161 test_line_count = 2 actual &&
162 cleanup_clone $enlistment
163 '
164
165 test_expect_success 'progress without tty' '
166 enlistment=progress2 &&
167
168 test_config -C to-clone uploadpack.allowfilter true &&
169 test_config -C to-clone uploadpack.allowanysha1inwant true &&
170
171 GIT_PROGRESS_DELAY=0 scalar clone "file://$(pwd)/to-clone" "$enlistment" 2>stderr &&
172 ! grep "Enumerating objects" stderr &&
173 ! grep "Updating files" stderr &&
174 cleanup_clone $enlistment
175 '
176
177 test_expect_success 'scalar clone warns when background maintenance fails' '
178 GIT_TEST_MAINT_SCHEDULER="crontab:false,launchctl:false,schtasks:false" \
179 scalar clone "file://$(pwd)/to-clone" maint-fail 2>err &&
180 grep "could not turn on maintenance" err
181 '
182
183 test_expect_success '`scalar clone --no-src`' '
184 scalar clone --src "file://$(pwd)/to-clone" with-src &&
185 scalar clone --no-src "file://$(pwd)/to-clone" without-src &&
186
187 test_path_is_dir with-src/src &&
188 test_path_is_missing without-src/src &&
189
190 (cd with-src/src && ls ?*) >with &&
191 (cd without-src && ls ?*) >without &&
192 test_cmp with without
193 '
194
195 test_done