Subject: Re: [PATCH v2 00/14] Sparse checkout

From: Nguyen Thai Ngoc Duy <[email-masked]>
Date: Tue, 23 Sep 2008 18:56:56 +0700

On Tue, Sep 23, 2008 at 01:06:47PM +0200, =?ISO-8859-1?Q?Santi_B=E9jar_ wrote:
> While I agree that the checkout attr looks like an attribute (so
> reusing attr.c is a good idea) and $GIT_DIR/info/gitattributes seems a
> good place to specify them, I think it will be better in the config
> $GIT_DIR/config. There it is clear that it is a local thing and you
> have "git config" to read and write them. Additionally you could have
> different patterns in the config (sparse.default, sparse.doc,
> sparse.src,...), although maybe it is not very useful.
> 
> I think the main UI to sparse checkout should be a default sparse
> pattern that is used for "all" commands, like merge, reset, and
> checkout. Now it is too easy to escape from the sparse checkout, when
> you merge or checkout a branch with new files, when doing a "git reset
> --hard" (when you abort a failed merge), or when doing a diff
> (specially when you pull).

It should not escape that easy (except newly added files). There is a
bug in my apply_narrow_spec() that effectively disables sparse
checkkout for other unpack_trees() calls except checkout/clone. Try
the below patch.

diff --git a/unpack-trees.c b/unpack-trees.c
index 10f377c..5bbe016 100644
--- a/unpack-trees.c
+++ b/unpack-trees.c
@@ -146,8 +146,10 @@ static int apply_narrow_spec(struct unpack_trees_options *o)
 	struct index_state *index = &o->result;
 	int i;
 
+	/*
 	if (!(o->new_narrow_path | o->add_narrow_path | o->remove_narrow_path))
 		return 0;
+	*/
 
 	for (i = 0; i < index->cache_nr; i++) {
 		struct cache_entry *ce = index->cache[i];
-- 
Duy