3 test_description
='test the `scalar clone` subcommand'
7 GIT_TEST_MAINT_SCHEDULER
="crontab:test-tool crontab cron.txt,launchctl:true,schtasks:true"
8 export GIT_TEST_MAINT_SCHEDULER
10 test_expect_success
'set up repository to clone' '
21 git switch -c parallel first &&
28 git config uploadpack.allowfilter true &&
29 git config uploadpack.allowanysha1inwant true
37 test_expect_success
'creates content in enlistment root' '
40 scalar clone "file://$(pwd)/to-clone" $enlistment &&
41 ls -A $enlistment >enlistment-root &&
42 test_line_count = 1 enlistment-root &&
43 test_path_is_dir $enlistment/src &&
44 test_path_is_dir $enlistment/src/.git &&
46 cleanup_clone $enlistment
49 test_expect_success
'with spaces' '
50 enlistment="cloned with space" &&
52 scalar clone "file://$(pwd)/to-clone" "$enlistment" &&
53 test_path_is_dir "$enlistment" &&
54 test_path_is_dir "$enlistment/src" &&
55 test_path_is_dir "$enlistment/src/.git" &&
57 cleanup_clone "$enlistment"
60 test_expect_success
'partial clone if supported by server' '
61 enlistment=partial-clone &&
63 scalar clone "file://$(pwd)/to-clone" $enlistment &&
68 # Two promisor packs: one for refs, the other for blobs
69 ls .git/objects/pack/pack-*.promisor >promisorlist &&
70 test_line_count = 2 promisorlist
73 cleanup_clone $enlistment
76 test_expect_success
'fall back on full clone if partial unsupported' '
77 enlistment=no-partial-support &&
79 test_config -C to-clone uploadpack.allowfilter false &&
80 test_config -C to-clone uploadpack.allowanysha1inwant false &&
82 scalar clone "file://$(pwd)/to-clone" $enlistment 2>err &&
83 grep "filtering not recognized by server, ignoring" err &&
88 # Still get a refs promisor file, but none for blobs
89 ls .git/objects/pack/pack-*.promisor >promisorlist &&
90 test_line_count = 1 promisorlist
93 cleanup_clone $enlistment
96 test_expect_success
'initializes sparse-checkout by default' '
99 scalar clone "file://$(pwd)/to-clone" $enlistment &&
101 cd $enlistment/src &&
102 test_cmp_config true core.sparseCheckout &&
103 test_cmp_config true core.sparseCheckoutCone
106 cleanup_clone $enlistment
109 test_expect_success
'--full-clone does not create sparse-checkout' '
110 enlistment=full-clone &&
112 scalar clone --full-clone "file://$(pwd)/to-clone" $enlistment &&
114 cd $enlistment/src &&
115 test_cmp_config "" --default "" core.sparseCheckout &&
116 test_cmp_config "" --default "" core.sparseCheckoutCone
119 cleanup_clone $enlistment
122 test_expect_success
'--single-branch clones HEAD only' '
123 enlistment=single-branch &&
125 scalar clone --single-branch "file://$(pwd)/to-clone" $enlistment &&
127 cd $enlistment/src &&
128 git for-each-ref refs/remotes/origin >out &&
129 test_line_count = 1 out &&
130 grep "refs/remotes/origin/base" out
133 cleanup_clone $enlistment
136 test_expect_success
'--no-single-branch clones all branches' '
137 enlistment=no-single-branch &&
139 scalar clone --no-single-branch "file://$(pwd)/to-clone" $enlistment &&
141 cd $enlistment/src &&
142 git for-each-ref refs/remotes/origin >out &&
143 test_line_count = 2 out &&
144 grep "refs/remotes/origin/base" out &&
145 grep "refs/remotes/origin/parallel" out
148 cleanup_clone $enlistment