]> git.ipfire.org Git - thirdparty/git.git/commitdiff
t5616: test cloning/fetching with sparse:oid=<oid> filter
authorJon Simons <jon@jonsimons.org>
Sun, 15 Sep 2019 01:11:16 +0000 (21:11 -0400)
committerJunio C Hamano <gitster@pobox.com>
Mon, 16 Sep 2019 19:47:17 +0000 (12:47 -0700)
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>
t/t5616-partial-clone.sh

index 565254558f362397270bcf13bd3566993e1b0f50..0bdbc819f1d680d368b87d000aba24fe033927b2 100755 (executable)
@@ -241,6 +241,42 @@ test_expect_success 'fetch what is specified on CLI even if already promised' '
        ! grep "?$(cat blob)" missing_after
 '
 
+test_expect_success 'setup src repo for sparse filter' '
+       git init sparse-src &&
+       git -C sparse-src config --local uploadpack.allowfilter 1 &&
+       git -C sparse-src config --local uploadpack.allowanysha1inwant 1 &&
+       test_commit -C sparse-src one &&
+       test_commit -C sparse-src two &&
+       echo /one.t >sparse-src/only-one &&
+       git -C sparse-src add . &&
+       git -C sparse-src commit -m "add sparse checkout files"
+'
+
+test_expect_failure 'partial clone with sparse filter succeeds' '
+       rm -rf dst.git &&
+       git clone --no-local --bare \
+                 --filter=sparse:oid=master:only-one \
+                 sparse-src dst.git &&
+       (
+               cd dst.git &&
+               git rev-list --objects --missing=print HEAD >out &&
+               grep "^$(git rev-parse HEAD:one.t)" out &&
+               grep "^?$(git rev-parse HEAD:two.t)" out
+       )
+'
+
+test_expect_failure 'partial clone with unresolvable sparse filter fails cleanly' '
+       rm -rf dst.git &&
+       test_must_fail git clone --no-local --bare \
+                                --filter=sparse:oid=master:no-such-name \
+                                sparse-src dst.git 2>err &&
+       test_i18ngrep "unable to access sparse blob in .master:no-such-name" err &&
+       test_must_fail git clone --no-local --bare \
+                                --filter=sparse:oid=master \
+                                sparse-src dst.git 2>err &&
+       test_i18ngrep "could not load filter specification" err
+'
+
 . "$TEST_DIRECTORY"/lib-httpd.sh
 start_httpd