Merge branch 'ab/run-hook-api-cleanup'
[git/debian.git] / t / t9211-scalar-clone.sh
blobdd33d87e9be16515276b4b75758ba5eb3a7f8d05
1 #!/bin/sh
3 test_description='test the `scalar clone` subcommand'
5 . ./test-lib.sh
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' '
11 rm -rf .git &&
12 git init to-clone &&
14 cd to-clone &&
15 git branch -m base &&
17 test_commit first &&
18 test_commit second &&
19 test_commit third &&
21 git switch -c parallel first &&
22 mkdir -p 1/2 &&
23 test_commit 1/2/3 &&
25 git switch base &&
27 # By default, permit
28 git config uploadpack.allowfilter true &&
29 git config uploadpack.allowanysha1inwant true
33 cleanup_clone () {
34 rm -rf "$1"
37 test_expect_success 'creates content in enlistment root' '
38 enlistment=cloned &&
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 &&
66 cd $enlistment/src &&
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
71 ) &&
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 &&
86 cd $enlistment/src &&
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
91 ) &&
93 cleanup_clone $enlistment
96 test_expect_success 'initializes sparse-checkout by default' '
97 enlistment=sparse &&
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
104 ) &&
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
117 ) &&
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
131 ) &&
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
146 ) &&
148 cleanup_clone $enlistment
151 test_done