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