Skip to content

Commit 5e82123

Browse files
pcloudsgitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent f696543 commit 5e82123

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

Documentation/git-read-tree.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -400,7 +400,7 @@ files are in. You can also specify what files are _not_ in, using
400400
negate patterns. For example, to remove file "unwanted":
401401

402402
----------------
403-
*
403+
/*
404404
!unwanted
405405
----------------
406406

@@ -412,7 +412,7 @@ directory with the `$GIT_DIR/info/sparse-checkout` file content as
412412
follows:
413413

414414
----------------
415-
*
415+
/*
416416
----------------
417417

418418
Then you can disable sparse checkout. Sparse checkout support in "git

0 commit comments

Comments
 (0)