* nd/maint-fix-add-typo-detection:
Revert "excluded_1(): support exclude files in index"
unpack-trees: fix sparse checkout's "unable to match directories"
unpack-trees: move all skip-worktree checks back to unpack_trees()
dir.c: add free_excludes()
cache.h: realign and use (1 << x) form for CE_* constants
@ -416,13 +416,6 @@ turn `core.sparseCheckout` on in order to have sparse checkout
@@ -416,13 +416,6 @@ turn `core.sparseCheckout` on in order to have sparse checkout
support.
BUGS
----
In order to match a directory with $GIT_DIR/info/sparse-checkout,
trailing slash must be used. The form without trailing slash, while
works with .gitignore, does not work with sparse checkout.
static int locate_in_src_index(struct cache_entry *ce,
@ -820,9 +811,177 @@ static int unpack_callback(int n, unsigned long mask, unsigned long dirmask, str
@@ -820,9 +811,177 @@ static int unpack_callback(int n, unsigned long mask, unsigned long dirmask, str
return mask;
}
/* Whole directory matching */
static int clear_ce_flags_dir(struct cache_entry **cache, int nr,
char *prefix, int prefix_len,
char *basename,
int select_mask, int clear_mask,
struct exclude_list *el)
{
struct cache_entry **cache_end = cache + nr;
int dtype = DT_DIR;
int ret = excluded_from_list(prefix, prefix_len, basename, &dtype, el);
prefix[prefix_len++] = '/';
/* included, no clearing for any entries under this directory */
if (!ret) {
for (; cache != cache_end; cache++) {
struct cache_entry *ce = *cache;
if (strncmp(ce->name, prefix, prefix_len))
break;
}
return nr - (cache_end - cache);
}
/* excluded, clear all selected entries under this directory. */
if (ret == 1) {
for (; cache != cache_end; cache++) {
struct cache_entry *ce = *cache;
if (select_mask && !(ce->ce_flags & select_mask))
continue;
if (strncmp(ce->name, prefix, prefix_len))
break;
ce->ce_flags &= ~clear_mask;
}
return nr - (cache_end - cache);
}
return 0;
}
/*
* Traverse the index, find every entry that matches according to
* o->el. Do "ce_flags &= ~clear_mask" on those entries. Return the
* number of traversed entries.
*
* If select_mask is non-zero, only entries whose ce_flags has on of
* those bits enabled are traversed.
*
* cache : pointer to an index entry
* prefix_len : an offset to its path
*
* The current path ("prefix") including the trailing '/' is
* cache[0]->name[0..(prefix_len-1)]
* Top level path has prefix_len zero.
*/
static int clear_ce_flags_1(struct cache_entry **cache, int nr,
char *prefix, int prefix_len,
int select_mask, int clear_mask,
struct exclude_list *el)
{
struct cache_entry **cache_end = cache + nr;
/*
* Process all entries that have the given prefix and meet
* select_mask condition
*/
while(cache != cache_end) {
struct cache_entry *ce = *cache;
const char *name, *slash;
int len, dtype;
if (select_mask && !(ce->ce_flags & select_mask)) {
cache++;
continue;
}
if (prefix_len && strncmp(ce->name, prefix, prefix_len))
break;
name = ce->name + prefix_len;
slash = strchr(name, '/');
/* If it's a directory, try whole directory match first */