Merge branch 'cp/git-flush-is-an-env-bool'
[alt-git.git] / t / t9211-scalar-clone.sh
blob7869f45ee646dd511b16e404a8b165200f9c8608
1 #!/bin/sh
3 test_description='test the `scalar clone` subcommand'
5 . ./test-lib.sh
6 . "${TEST_DIRECTORY}/lib-terminal.sh"
8 GIT_TEST_MAINT_SCHEDULER="crontab:test-tool crontab cron.txt,launchctl:true,schtasks:true"
9 export GIT_TEST_MAINT_SCHEDULER
11 test_expect_success 'set up repository to clone' '
12 rm -rf .git &&
13 git init to-clone &&
15 cd to-clone &&
16 git branch -m base &&
18 test_commit first &&
19 test_commit second &&
20 test_commit third &&
22 git switch -c parallel first &&
23 mkdir -p 1/2 &&
24 test_commit 1/2/3 &&
26 git switch base &&
28 # By default, permit
29 git config uploadpack.allowfilter true &&
30 git config uploadpack.allowanysha1inwant true
34 cleanup_clone () {
35 rm -rf "$1"
38 test_expect_success 'creates content in enlistment root' '
39 enlistment=cloned &&
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 &&
47 cleanup_clone $enlistment
50 test_expect_success 'with spaces' '
51 enlistment="cloned with space" &&
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" &&
58 cleanup_clone "$enlistment"
61 test_expect_success 'partial clone if supported by server' '
62 enlistment=partial-clone &&
64 scalar clone "file://$(pwd)/to-clone" $enlistment &&
67 cd $enlistment/src &&
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 ) &&
74 cleanup_clone $enlistment
77 test_expect_success 'fall back on full clone if partial unsupported' '
78 enlistment=no-partial-support &&
80 test_config -C to-clone uploadpack.allowfilter false &&
81 test_config -C to-clone uploadpack.allowanysha1inwant false &&
83 scalar clone "file://$(pwd)/to-clone" $enlistment 2>err &&
84 grep "filtering not recognized by server, ignoring" err &&
87 cd $enlistment/src &&
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 ) &&
94 cleanup_clone $enlistment
97 test_expect_success 'initializes sparse-checkout by default' '
98 enlistment=sparse &&
100 scalar clone "file://$(pwd)/to-clone" $enlistment &&
102 cd $enlistment/src &&
103 test_cmp_config true core.sparseCheckout &&
104 test_cmp_config true core.sparseCheckoutCone
105 ) &&
107 cleanup_clone $enlistment
110 test_expect_success '--full-clone does not create sparse-checkout' '
111 enlistment=full-clone &&
113 scalar clone --full-clone "file://$(pwd)/to-clone" $enlistment &&
115 cd $enlistment/src &&
116 test_cmp_config "" --default "" core.sparseCheckout &&
117 test_cmp_config "" --default "" core.sparseCheckoutCone
118 ) &&
120 cleanup_clone $enlistment
123 test_expect_success '--single-branch clones HEAD only' '
124 enlistment=single-branch &&
126 scalar clone --single-branch "file://$(pwd)/to-clone" $enlistment &&
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 ) &&
134 cleanup_clone $enlistment
137 test_expect_success '--no-single-branch clones all branches' '
138 enlistment=no-single-branch &&
140 scalar clone --no-single-branch "file://$(pwd)/to-clone" $enlistment &&
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 ) &&
149 cleanup_clone $enlistment
152 test_expect_success TTY 'progress with tty' '
153 enlistment=progress1 &&
155 test_config -C to-clone uploadpack.allowfilter true &&
156 test_config -C to-clone uploadpack.allowanysha1inwant true &&
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
165 test_expect_success 'progress without tty' '
166 enlistment=progress2 &&
168 test_config -C to-clone uploadpack.allowfilter true &&
169 test_config -C to-clone uploadpack.allowanysha1inwant true &&
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
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
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 &&
187 test_path_is_dir with-src/src &&
188 test_path_is_missing without-src/src &&
190 (cd with-src/src && ls ?*) >with &&
191 (cd without-src && ls ?*) >without &&
192 test_cmp with without
195 test_done