Code

git-read-tree.txt: update sparse checkout examples
authorNguyễn Thái Ngọc Duy <pclouds@gmail.com>
Sun, 25 Sep 2011 23:09:15 +0000 (09:09 +1000)
committerJunio C Hamano <gitster@pobox.com>
Mon, 26 Sep 2011 17:00:44 +0000 (10:00 -0700)
commit5e82123197229d823a5838126dce20f33f82fe27
tree98c0c48694962978dc508f70259c3985939ebffa
parentf696543dad6c7ba27b0c4fab167a5687263a9ba0
git-read-tree.txt: update sparse checkout examples

The negation example uses '*' to match everything. This used to work
before 9037026 (unpack-trees: fix sparse checkout's "unable to match
directories") because back then, the list of paths is used to match
sparse patterns, so with the patterns

    *
    !subdir/

subdir/ always matches any path that start with subdir/ and "*" has no
chance to get tested. The result is subdir is excluded.

After the said commit, a tree structure is dynamically created and
sparse pattern matching now follows closely how read_directory()
applies .gitignore. This solves one problem, but reveals another one.

With this new strategy, "!subdir/" rule will be only tested once when
"subdir" directory is examined. Entries inside subdir, when examined,
will match "*" and are (correctly) re-added again because any rules
without a slash will match at every directory level. In the end, "*"
can revert every negation rules.

In order to correctly exclude subdir, we must use

    /*
    !subdir

to limit "match all" rule at top level only.

"*" rule has no actual use in sparse checkout and can be confusing to
users. While we can automatically turn "*" to "/*", this violates
.gitignore definition. Instead, discourage "*" in favor of "/*" (in
the second example).

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