Add explanation why we do not allow to sparse checkout to empty working tree

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Nguyễn Thái Ngọc Duy committed Sep 22, 2011 at 21:24 UTC a7bc906f2e64f0d9d3fec91964dc38e390ef69a1
1 file changed +6 -1
unpack-trees.c
+6 -1
@@ -1119,8 +1119,13 @@ int unpack_trees(unsigned len, struct tree_desc *t, struct unpack_trees_options
1119 }
1120 if (ret < 0)
1121 goto return_failed;
1122 + /*
1123 + * Sparse checkout is meant to narrow down checkout area
1124 + * but it does not make sense to narrow down to empty working
1125 + * tree. This is usually a mistake in sparse checkout rules.
1126 + * Do not allow users to do that.
1127 + */
1128 if (o->result.cache_nr && empty_worktree) {
1123 - /* dubious---why should this fail??? */
1129 ret = unpack_failed(o, "Sparse checkout leaves no entry on working directory");
1130 goto done;
1131 }