3 test_description
='test the `scalar clone` subcommand'
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' '
22 git switch -c parallel first &&
29 git config uploadpack.allowfilter true &&
30 git config uploadpack.allowanysha1inwant true
38 test_expect_success
'creates content in enlistment root' '
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 &&
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
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 &&
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
94 cleanup_clone $enlistment
97 test_expect_success
'initializes sparse-checkout by default' '
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
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
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
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
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