path: root/Documentation/git-sparse-checkout.txt
diff options
authorDerrick Stolee <>2019-11-21 22:04:40 (GMT)
committerJunio C Hamano <>2019-11-22 07:11:44 (GMT)
commit879321eb0bec25779386445d65242452825155be (patch)
treee7a7f3a7c1e755c8b91e45666c60fae7f818b36c /Documentation/git-sparse-checkout.txt
parente6152e35ff287ab58e2c17065f02cb1be9f4a0aa (diff)
sparse-checkout: add 'cone' mode
The sparse-checkout feature can have quadratic performance as the number of patterns and number of entries in the index grow. If there are 1,000 patterns and 1,000,000 entries, this time can be very significant. Create a new Boolean config option, core.sparseCheckoutCone, to indicate that we expect the sparse-checkout file to contain a more limited set of patterns. This is a separate config setting from core.sparseCheckout to avoid breaking older clients by introducing a tri-state option. The config option does nothing right now, but will be expanded upon in a later commit. Signed-off-by: Derrick Stolee <> Signed-off-by: Junio C Hamano <>
Diffstat (limited to 'Documentation/git-sparse-checkout.txt')
1 files changed, 54 insertions, 1 deletions
diff --git a/Documentation/git-sparse-checkout.txt b/Documentation/git-sparse-checkout.txt
index c2cb19f..8535f0c 100644
--- a/Documentation/git-sparse-checkout.txt
+++ b/Documentation/git-sparse-checkout.txt
@@ -80,7 +80,9 @@ the sparse-checkout file.
To repopulate the working directory with all files, use the
`git sparse-checkout disable` command.
By default, the sparse-checkout file uses the same syntax as `.gitignore`
@@ -95,6 +97,57 @@ using negative patterns. For example, to remove the file `unwanted`:
+The full pattern set allows for arbitrary pattern matches and complicated
+inclusion/exclusion rules. These can result in O(N*M) pattern matches when
+updating the index, where N is the number of patterns and M is the number
+of paths in the index. To combat this performance issue, a more restricted
+pattern set is allowed when `core.spareCheckoutCone` is enabled.
+The accepted patterns in the cone pattern set are:
+1. *Recursive:* All paths inside a directory are included.
+2. *Parent:* All files immediately inside a directory are included.
+In addition to the above two patterns, we also expect that all files in the
+root directory are included. If a recursive pattern is added, then all
+leading directories are added as parent patterns.
+By default, when running `git sparse-checkout init`, the root directory is
+added as a parent pattern. At this point, the sparse-checkout file contains
+the following patterns:
+This says "include everything in root, but nothing two levels below root."
+If we then add the folder `A/B/C` as a recursive pattern, the folders `A` and
+`A/B` are added as parent patterns. The resulting sparse-checkout file is
+Here, order matters, so the negative patterns are overridden by the positive
+patterns that appear lower in the file.
+If `core.sparseCheckoutCone=true`, then Git will parse the sparse-checkout file
+expecting patterns of these types. Git will warn if the patterns do not match.
+If the patterns do match the expected format, then Git will use faster hash-
+based algorithms to compute inclusion in the sparse-checkout.