]> git.ipfire.org Git - thirdparty/git.git/commit - t/t1011-read-tree-sparse-checkout.sh
sparse-checkout: stop blocking empty workdirs
authorDerrick Stolee <dstolee@microsoft.com>
Mon, 4 May 2020 18:27:43 +0000 (18:27 +0000)
committerJunio C Hamano <gitster@pobox.com>
Mon, 4 May 2020 19:57:15 +0000 (12:57 -0700)
commitace224ac5fb120e9cae894e31713ab60e91f141f
tree89ebc967f82c94fb619d336bf1f80f43afe5f0ae
parent5644ca28cded68972c74614fc06d6e0e1db1a7de
sparse-checkout: stop blocking empty workdirs

Remove the error condition when updating the sparse-checkout leaves
an empty working directory.

This behavior was added in 9e1afb167 (sparse checkout: inhibit empty
worktree, 2009-08-20). The comment was added in a7bc906f2 (Add
explanation why we do not allow to sparse checkout to empty working
tree, 2011-09-22) in response to a "dubious" comment in 84563a624
(unpack-trees.c: cosmetic fix, 2010-12-22).

With the recent "cone mode" and "git sparse-checkout init [--cone]"
command, it is common to set a reasonable sparse-checkout pattern
set of

/*
!/*/

which matches only files at root. If the repository has no such files,
then their "git sparse-checkout init" command will fail.

Now that we expect this to be a common pattern, we should not have the
commands fail on an empty working directory. If it is a confusing
result, then the user can recover with "git sparse-checkout disable"
or "git sparse-checkout set". This is especially simple when using cone
mode.

Reported-by: Lars Schneider <larsxschneider@gmail.com>
Signed-off-by: Derrick Stolee <dstolee@microsoft.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
t/t1011-read-tree-sparse-checkout.sh
t/t1091-sparse-checkout-builtin.sh
unpack-trees.c