t5616: test cloning/fetching with sparse:oid=<oid> filter
We test in t5317 that "sparse:oid" filters work with rev-list, but there's no coverage at all confirming that they work with a fetch or clone (and in fact, there are several bugs). Let's do a basic test that a clone fetches the correct objects. [jk: extracted from Jon's earlier fix patches. I also simplified the setup down to a single sparse file, and I added checks that we got the right blobs] Signed-off-by: Jon Simons <jon@jonsimons.org> Signed-off-by: Jeff King <peff@peff.net> Acked-by: Jeff Hostetler <jeffhost@microsoft.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Jon Simons committed
Sep 14, 2019 at 21:11 UTC
72de5895ed4d84ad23bd29e48ec613c9117e7117
1 file changed
+36
t/t5616-partial-clone.sh
+36
@@ -241,6 +241,42 @@ test_expect_success 'fetch what is specified on CLI even if already promised' '
241
! grep "?$(cat blob)" missing_after
242
'
243
244
+test_expect_success 'setup src repo for sparse filter' '
245
+ git init sparse-src &&
246
+ git -C sparse-src config --local uploadpack.allowfilter 1 &&
247
+ git -C sparse-src config --local uploadpack.allowanysha1inwant 1 &&
248
+ test_commit -C sparse-src one &&
249
+ test_commit -C sparse-src two &&
250
+ echo /one.t >sparse-src/only-one &&
251
+ git -C sparse-src add . &&
252
+ git -C sparse-src commit -m "add sparse checkout files"
253
+'
254
+
255
+test_expect_failure 'partial clone with sparse filter succeeds' '
256
+ rm -rf dst.git &&
257
+ git clone --no-local --bare \
258
+ --filter=sparse:oid=master:only-one \
259
+ sparse-src dst.git &&
260
+ (
261
+ cd dst.git &&
262
+ git rev-list --objects --missing=print HEAD >out &&
263
+ grep "^$(git rev-parse HEAD:one.t)" out &&
264
+ grep "^?$(git rev-parse HEAD:two.t)" out
265
+ )
266
+'
267
+
268
+test_expect_failure 'partial clone with unresolvable sparse filter fails cleanly' '
269
+ rm -rf dst.git &&
270
+ test_must_fail git clone --no-local --bare \
271
+ --filter=sparse:oid=master:no-such-name \
272
+ sparse-src dst.git 2>err &&
273
+ test_i18ngrep "unable to access sparse blob in .master:no-such-name" err &&
274
+ test_must_fail git clone --no-local --bare \
275
+ --filter=sparse:oid=master \
276
+ sparse-src dst.git 2>err &&
277
+ test_i18ngrep "could not load filter specification" err
278
+'
279
+
280
. "$TEST_DIRECTORY"/lib-httpd.sh
281
start_httpd
282