1
0
mirror of https://github.com/git/git.git synced 2024-09-28 23:11:39 +02:00

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>
This commit is contained in:
Jon Simons 2019-09-14 21:11:16 -04:00 committed by Junio C Hamano
parent 745f681289
commit 72de5895ed

@ -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