Hi Frédéric and Duy,

Frédéric Brière wrote:

> Despite what git-read-tree(1) says, the syntax for sparse-checkout
> appears to be much stricter for directories, requiring a trailing slash
> and no leading slash.

Sorry to let this sit for so long.

Sparse checkout shares the .gitignore machinery
add_excludes_from_file_to_list to populate its exclude_list (see
v1.7.0-rc0~103^2~11).

So it is the semantics (v1.7.0-rc0~103^2~10) rather than syntax that
requires investigation.  Unlike read_directory which walks through the
directory hierarchy and checks each ancestor using per-dir exclude
lists on the way, sparse checkout does its checking against entire
index entries.

 static int will_have_skip_worktree(const struct cache_entry *ce, struct 
unpack_trees_options *o)
 {
        const char *basename;

        if (ce_stage(ce))
                return 0;

        basename = strrchr(ce->name, '/');
        basename = basename ? basename+1 : ce->name;
        return excluded_from_list(ce->name, ce_namelen(ce), basename, NULL, 
o->el) <= 0;
 }

Problems:

 1. ce->name does not have a / in front, so anchored exclusion entries
    never match.

 2. because we do not do the ancestor walk, exclusions for directories
    need to have EXC_FLAG_MUSTBEDIR set (i.e., trailing /) so they are
    matched using prefixcmp() instead of strcmp()

 3. the prefixcmp() does not include a trailing '/' for some reason.
    So including t/ in your sparse-checkout for git will pull in many
    false positives

 4. wildcards apply to the entire filename

Thanks for reporting and for writing the sparse checkout code,
respectively. :)

Thoughts?



-- 
To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org

Reply via email to