Subject: Re: [PATCH 05/10] unpack-trees: optimize full checkout case

From: Jonathan Nieder <[email-masked]>
Date: Mon, 15 Nov 2010 14:41:58 -0600

Nguyễn Thái Ngọc Duy wrote:

> Signed-off-by: Nguyễn Thái Ngọc Duy <[email-masked]>

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 = &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.