@@ -4,6 +4,14 @@ test_description='sparse checkout builtin tests'
4
4
5
5
. ./test-lib.sh
6
6
7
+ list_files () {
8
+ # Do not replace this with 'ls "$1"', as "ls" with BSD-lineage
9
+ # enables "-A" by default for root and ends up including ".git" and
10
+ # such in its output. (Note, though, that running the test suite as
11
+ # root is generally not recommended.)
12
+ (cd " $1 " && printf ' %s\n' * )
13
+ }
14
+
7
15
test_expect_success ' setup' '
8
16
git init repo &&
9
17
(
@@ -50,7 +58,7 @@ test_expect_success 'git sparse-checkout init' '
50
58
EOF
51
59
test_cmp expect repo/.git/info/sparse-checkout &&
52
60
test_cmp_config -C repo true core.sparsecheckout &&
53
- ls repo >dir &&
61
+ list_files repo >dir &&
54
62
echo a >expect &&
55
63
test_cmp expect dir
56
64
'
@@ -73,7 +81,7 @@ test_expect_success 'init with existing sparse-checkout' '
73
81
*folder*
74
82
EOF
75
83
test_cmp expect repo/.git/info/sparse-checkout &&
76
- ls repo >dir &&
84
+ list_files repo >dir &&
77
85
cat >expect <<-EOF &&
78
86
a
79
87
folder1
@@ -90,7 +98,7 @@ test_expect_success 'clone --sparse' '
90
98
!/*/
91
99
EOF
92
100
test_cmp expect actual &&
93
- ls clone >dir &&
101
+ list_files clone >dir &&
94
102
echo a >expect &&
95
103
test_cmp expect dir
96
104
'
@@ -119,7 +127,7 @@ test_expect_success 'set sparse-checkout using builtin' '
119
127
git -C repo sparse-checkout list >actual &&
120
128
test_cmp expect actual &&
121
129
test_cmp expect repo/.git/info/sparse-checkout &&
122
- ls repo >dir &&
130
+ list_files repo >dir &&
123
131
cat >expect <<-EOF &&
124
132
a
125
133
folder1
@@ -139,7 +147,7 @@ test_expect_success 'set sparse-checkout using --stdin' '
139
147
git -C repo sparse-checkout list >actual &&
140
148
test_cmp expect actual &&
141
149
test_cmp expect repo/.git/info/sparse-checkout &&
142
- ls repo >dir &&
150
+ list_files repo >dir &&
143
151
cat >expect <<-EOF &&
144
152
a
145
153
folder1
@@ -154,7 +162,7 @@ test_expect_success 'cone mode: match patterns' '
154
162
git -C repo read-tree -mu HEAD 2>err &&
155
163
test_i18ngrep ! "disabling cone patterns" err &&
156
164
git -C repo reset --hard &&
157
- ls repo >dir &&
165
+ list_files repo >dir &&
158
166
cat >expect <<-EOF &&
159
167
a
160
168
folder1
@@ -177,7 +185,7 @@ test_expect_success 'sparse-checkout disable' '
177
185
test_path_is_file repo/.git/info/sparse-checkout &&
178
186
git -C repo config --list >config &&
179
187
test_must_fail git config core.sparseCheckout &&
180
- ls repo >dir &&
188
+ list_files repo >dir &&
181
189
cat >expect <<-EOF &&
182
190
a
183
191
deep
@@ -191,24 +199,24 @@ test_expect_success 'cone mode: init and set' '
191
199
git -C repo sparse-checkout init --cone &&
192
200
git -C repo config --list >config &&
193
201
test_i18ngrep "core.sparsecheckoutcone=true" config &&
194
- ls repo >dir &&
202
+ list_files repo >dir &&
195
203
echo a >expect &&
196
204
test_cmp expect dir &&
197
205
git -C repo sparse-checkout set deep/deeper1/deepest/ 2>err &&
198
206
test_must_be_empty err &&
199
- ls repo >dir &&
207
+ list_files repo >dir &&
200
208
cat >expect <<-EOF &&
201
209
a
202
210
deep
203
211
EOF
204
212
test_cmp expect dir &&
205
- ls repo/deep >dir &&
213
+ list_files repo/deep >dir &&
206
214
cat >expect <<-EOF &&
207
215
a
208
216
deeper1
209
217
EOF
210
218
test_cmp expect dir &&
211
- ls repo/deep/deeper1 >dir &&
219
+ list_files repo/deep/deeper1 >dir &&
212
220
cat >expect <<-EOF &&
213
221
a
214
222
deepest
@@ -234,7 +242,7 @@ test_expect_success 'cone mode: init and set' '
234
242
folder1
235
243
folder2
236
244
EOF
237
- ls repo >dir &&
245
+ list_files repo >dir &&
238
246
test_cmp expect dir
239
247
'
240
248
@@ -256,7 +264,7 @@ test_expect_success 'revert to old sparse-checkout on bad update' '
256
264
test_must_fail git -C repo sparse-checkout set deep/deeper1 2>err &&
257
265
test_i18ngrep "cannot set sparse-checkout patterns" err &&
258
266
test_cmp repo/.git/info/sparse-checkout expect &&
259
- ls repo/deep >dir &&
267
+ list_files repo/deep >dir &&
260
268
cat >expect <<-EOF &&
261
269
a
262
270
deeper1
@@ -313,7 +321,7 @@ test_expect_success 'cone mode: set with core.ignoreCase=true' '
313
321
/folder1/
314
322
EOF
315
323
test_cmp expect repo/.git/info/sparse-checkout &&
316
- ls repo >dir &&
324
+ list_files repo >dir &&
317
325
cat >expect <<-EOF &&
318
326
a
319
327
folder1
0 commit comments