aboutsummaryrefslogtreecommitdiff
path: root/unpack-trees.c
diff options
context:
space:
mode:
authorNguyễn Thái Ngọc Duy <pclouds@gmail.com>2009-08-20 20:47:13 +0700
committerJunio C Hamano <gitster@pobox.com>2009-08-23 17:14:42 -0700
commit9e1afb16753d583a696c988d33f45655f81e8f7c (patch)
tree0ad696855e2031ebd059dc585810ad24605ee859 /unpack-trees.c
parentd6b38f61c8125423abdf2b9c10f2187c5fecd80e (diff)
downloadgit-9e1afb16753d583a696c988d33f45655f81e8f7c.tar.gz
git-9e1afb16753d583a696c988d33f45655f81e8f7c.tar.xz
sparse checkout: inhibit empty worktree
The way sparse checkout works, users may empty their worktree completely, because of non-matching sparse-checkout spec, or empty spec. I believe this is not desired. This patch makes Git refuse to produce such worktree. Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'unpack-trees.c')
-rw-r--r--unpack-trees.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/unpack-trees.c b/unpack-trees.c
index 72743b34d..80ae2a0f4 100644
--- a/unpack-trees.c
+++ b/unpack-trees.c
@@ -498,6 +498,7 @@ int unpack_trees(unsigned len, struct tree_desc *t, struct unpack_trees_options
}
if (!o->skip_sparse_checkout) {
+ int empty_worktree = 1;
for (i = 0;i < o->result.cache_nr;i++) {
struct cache_entry *ce = o->result.cache[i];
@@ -512,8 +513,14 @@ int unpack_trees(unsigned len, struct tree_desc *t, struct unpack_trees_options
*/
if (ce_skip_worktree(ce))
ce->ce_flags &= ~(CE_UPDATE | CE_REMOVE);
+ else
+ empty_worktree = 0;
}
+ if (o->result.cache_nr && empty_worktree) {
+ ret = unpack_failed(o, "Sparse checkout leaves no entry on working directory");
+ goto done;
+ }
}
o->src_index = NULL;