From 5e82123197229d823a5838126dce20f33f82fe27 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Nguy=E1=BB=85n=20Th=C3=A1i=20Ng=E1=BB=8Dc=20Duy?= Date: Mon, 26 Sep 2011 09:09:15 +1000 Subject: [PATCH] git-read-tree.txt: update sparse checkout examples MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit 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 Signed-off-by: Junio C Hamano --- Documentation/git-read-tree.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Documentation/git-read-tree.txt b/Documentation/git-read-tree.txt index 46a96f231..e9f4355d7 100644 --- a/Documentation/git-read-tree.txt +++ b/Documentation/git-read-tree.txt @@ -400,7 +400,7 @@ files are in. You can also specify what files are _not_ in, using negate patterns. For example, to remove file "unwanted": ---------------- -* +/* !unwanted ---------------- @@ -412,7 +412,7 @@ directory with the `$GIT_DIR/info/sparse-checkout` file content as follows: ---------------- -* +/* ---------------- Then you can disable sparse checkout. Sparse checkout support in "git -- 2.30.2