]> git.ipfire.org Git - thirdparty/git.git/commit - unpack-trees.c
unpack-trees: fix sparse checkout's "unable to match directories"
authorNguyễn Thái Ngọc Duy <pclouds@gmail.com>
Fri, 26 Nov 2010 18:17:46 +0000 (01:17 +0700)
committerJunio C Hamano <gitster@pobox.com>
Wed, 1 Dec 2010 01:28:09 +0000 (17:28 -0800)
commit9037026d34907c0c94e3ab46f96068fa57da6ebc
tree420b92db44369dd874ca93b4ae3aa28da7736034
parent2431afbf1b3b986245242218b909cd9f055ba65b
unpack-trees: fix sparse checkout's "unable to match directories"

Matching index entries against an excludes file currently has two
problems.

First, there's no function to do it.  Code paths (like sparse
checkout) that wanted to try it would iterate over index entries and
for each index entry pass that path to excluded_from_list().  But that
is not how excluded_from_list() works; one is supposed to feed in each
ancester of a path before a given path to find out if it was excluded
because of some parent or grandparent matching a

  bigsubdirectory/

pattern despite the path not matching any .gitignore pattern directly.

Second, it's inefficient.  The excludes mechanism is supposed to let
us block off vast swaths of the filesystem as uninteresting; separately
checking every index entry doesn't fit that model.

Introduce a new function to take care of both these problems.  This
traverses the index in depth-first order (well, that's what order the
index is in) to mark un-excluded entries.

Maybe some day the in-core index format will be restructured to make
this sort of operation easier.  Or maybe we will want to try some
binary search based thing.  The interface is simple enough to allow
all those things.  Example:

  clear_ce_flags(the_index.cache, the_index.cache_nr,
                 CE_CANDIDATE, CE_CLEARME, exclude_list);

would clear the CE_CLEARME flag on all index entries with
CE_CANDIDATE flag and not matched by exclude_list.

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Documentation/git-read-tree.txt
t/t1011-read-tree-sparse-checkout.sh
unpack-trees.c