sparse-checkout: stop blocking empty workdirs
Remove the error condition when updating the sparse-checkout leaves an empty working directory. This behavior was added in9e1afb167
(sparse checkout: inhibit empty worktree, 2009-08-20). The comment was added ina7bc906f2
(Add explanation why we do not allow to sparse checkout to empty working tree, 2011-09-22) in response to a "dubious" comment in84563a624
(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>
This commit is contained in:

committed by
Junio C Hamano

parent
5644ca28cd
commit
ace224ac5f
@ -74,13 +74,19 @@ test_expect_success 'read-tree --no-sparse-checkout with empty .git/info/sparse-
|
||||
test_expect_success 'read-tree with empty .git/info/sparse-checkout' '
|
||||
git config core.sparsecheckout true &&
|
||||
echo >.git/info/sparse-checkout &&
|
||||
read_tree_u_must_fail -m -u HEAD &&
|
||||
read_tree_u_must_succeed -m -u HEAD &&
|
||||
git ls-files --stage >result &&
|
||||
test_cmp expected result &&
|
||||
git ls-files -t >result &&
|
||||
cat >expected.swt <<-\EOF &&
|
||||
S init.t
|
||||
S sub/added
|
||||
S sub/addedtoo
|
||||
S subsub/added
|
||||
EOF
|
||||
test_cmp expected.swt result &&
|
||||
test -f init.t &&
|
||||
test -f sub/added
|
||||
! test -f init.t &&
|
||||
! test -f sub/added
|
||||
'
|
||||
|
||||
test_expect_success 'match directories with trailing slash' '
|
||||
|
Reference in New Issue
Block a user