From: Jonathan Nieder Date: Mon, 15 Nov 2010 20:41:58 GMT Subject: Re: [PATCH 05/10] unpack-trees: optimize full checkout case Message-ID: <20101115204158.GG16385@burratino> In-Reply-To: <1289817410-32470-6-git-send-email-pclouds@gmail.com> Nguyễn Thái Ngọc Duy wrote: > Signed-off-by: Nguyễn Thái Ngọc Duy So, what does it do? What workflow was not optimized (yes, I know full checkout means pattern "*", but the reader might not), why ought it to be optimized, and what are the side-effects, if any? > --- a/unpack-trees.c > +++ b/unpack-trees.c > @@ -996,6 +996,16 @@ int unpack_trees(unsigned len, struct tree_desc *t, struct unpack_trees_options > o->el = ⪙ > } > > + if (!o->skip_sparse_checkout && > + o->el->nr == 1 && > + !strcmp(o->el->excludes[0]->pattern, "*")) { > + for (i = 0; i < o->src_index->cache_nr; i++) > + if (ce_skip_worktree(o->src_index->cache[i])) > + break; > + if (i == o->src_index->cache_nr) > + o->skip_sparse_checkout = 1; Millinit: if (!o->skip_sparse_checkout && checkout_is_whole_tree(o) && index_uses_flag(o->src_index, CE_SKIP_WORKTREE)) o->skip_sparse_checkout = 1; Functions for the two conditions (especially the second) would make this clearer, I think. Sensible.