git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH v3 8/9] git-sparse-checkout.txt: mark non-cone mode as deprecated

From
Elijah Newren via GitGitGadget <gitgitgadget@gmail.com>
Date
Apr 22, 2022, 02:32 UTC
Message-ID
<a1b68fd6126eb341ef3637bb93fedad4309b36d0.1650594746.git.gitgitgadget@gmail.com>
In-Reply-To
<pull.1148.v3.git.1650594746.gitgitgadget@gmail.com>
From: Elijah Newren <newren@gmail.com>

While we have no current plans to actually remove --no-cone mode, we think users would be better off not using it. Update the documentation accordingly, including explaining why we think non-cone mode is problematic for users.

Signed-off-by: Elijah Newren <newren@gmail.com>
---
 Documentation/git-sparse-checkout.txt | 98 +++++++++++++++++++++++++--
 1 file changed, 94 insertions(+), 4 deletions(-)
diff --git a/Documentation/git-sparse-checkout.txt b/Documentation/git-sparse-checkout.txt
index 6e32034511d..c65d0ce96bb 100644
--- a/Documentation/git-sparse-checkout.txt
+++ b/Documentation/git-sparse-checkout.txt
@@ -71,10 +71,9 @@ and `--cone` needed to be specified or `core.sparseCheckoutCone` needed
 to be enabled.
 +
 When `--no-cone` is passed, the input list is considered a list of
-patterns.  This mode is harder to use and less performant, and is thus
-not recommended.  See the "Sparse Checkout" section of
-linkgit:git-read-tree[1] and the "Internals...Pattern Set" sections
-below for more details.
+patterns.  This mode has a number of drawbacks, including not working
+with some options like `--sparse-index`.  As explained in the
+"Non-cone Problems" section below, we do not recommend using it.
 +
 Use the `--[no-]sparse-index` option to use a sparse index (the
 default is to not use it).  A sparse index reduces the size of the
@@ -191,6 +190,97 @@ directory, it updates the skip-worktree bits in the index based
 on this file. The files matching the patterns in the file will
 appear in the working directory, and the rest will not.
 
+INTERNALS -- NON-CONE PROBLEMS
+------------------------------
+
+The `$GIT_DIR/info/sparse-checkout` file populated by the `set` and
+`add` subcommands is defined to be a bunch of patterns (one per line)
+using the same syntax as `.gitignore` files.  In cone mode, these
+patterns are restricted to matching directories (and users only ever
+need supply or see directory names), while in non-cone mode any
+gitignore-style pattern is permitted.  Using the full gitignore-style
+patterns in non-cone mode has a number of shortcomings:
+
+  * Fundamentally, it makes various worktree-updating processes (pull,
+    merge, rebase, switch, reset, checkout, etc.) require O(N*M) pattern
+    matches, where N is the number of patterns and M is the number of
+    paths in the index.  This scales poorly.
+
+  * Avoiding the scaling issue has to be done via limiting the number
+    of patterns via specifying leading directory name or glob.
+
+  * Passing globs on the command line is error-prone as users may
+    forget to quote the glob, causing the shell to expand it into all
+    matching files and pass them all individually along to
+    sparse-checkout set/add.  While this could also be a problem with
+    e.g. "git grep -- *.c", mistakes with grep/log/status appear in
+    the immediate output.  With sparse-checkout, the mistake gets
+    recorded at the time the sparse-checkout command is run and might
+    not be problematic until the user later switches branches or rebases
+    or merges, thus putting a delay between the user's error and when
+    they have a chance to catch/notice it.
+
+  * Related to the previous item, sparse-checkout has an 'add'
+    subcommand but no 'remove' subcommand.  Even if a 'remove'
+    subcommand were added, undoing an accidental unquoted glob runs
+    the risk of "removing too much", as it may remove entries that had
+    been included before the accidental add.
+
+  * Non-cone mode uses gitignore-style patterns to select what to
+    *include* (with the exception of negated patterns), while
+    .gitignore files use gitignore-style patterns to select what to
+    *exclude* (with the exception of negated patterns).  The
+    documentation on gitignore-style patterns usually does not talk in
+    terms of matching or non-matching, but on what the user wants to
+    "exclude".  This can cause confusion for users trying to learn how
+    to specify sparse-checkout patterns to get their desired behavior.
+
+  * Every other git subcommand that wants to provide "special path
+    pattern matching" of some sort uses pathspecs, but non-cone mode
+    for sparse-checkout uses gitignore patterns, which feels
+    inconsistent.
+
+  * It has edge cases where the "right" behavior is unclear.  Two examples:
+
+    First, two users are in a subdirectory, and the first runs
+       git sparse-checkout set '/toplevel-dir/*.c'
+    while the second runs
+       git sparse-checkout set relative-dir
+    Should those arguments be transliterated into
+       current/subdirectory/toplevel-dir/*.c
+    and
+       current/subdirectory/relative-dir
+    before inserting into the sparse-checkout file?  The user who typed
+    the first command is probably aware that arguments to set/add are
+    supposed to be patterns in non-cone mode, and probably would not be
+    happy with such a transliteration.  However, many gitignore-style
+    patterns are just paths, which might be what the user who typed the
+    second command was thinking, and they'd be upset if their argument
+    wasn't transliterated.
+
+    Second, what should bash-completion complete on for set/add commands
+    for non-cone users?  If it suggests paths, is it exacerbating the
+    problem above?  Also, if it suggests paths, what if the user has a
+    file or directory that begins with either a '!' or '#' or has a '*',
+    '\', '?', '[', or ']' in its name?  And if it suggests paths, will
+    it complete "/pro" to "/proc" (in the root filesytem) rather than to
+    "/progress.txt" in the current directory?  (Note that users are
+    likely to want to start paths with a leading '/' in non-cone mode,
+    for the same reason that .gitignore files often have one.)
+    Completing on files or directories might give nasty surprises in
+    all these cases.
+
+  * The excessive flexibility made other extensions essentially
+    impractical.  `--sparse-index` is likely impossible in non-cone
+    mode; even if it is somehow feasible, it would have been far more
+    work to implement and may have been too slow in practice.  Some
+    ideas for adding coupling between partial clones and sparse
+    checkouts are only practical with a more restricted set of paths
+    as well.
+
+For all these reasons, non-cone mode is deprecated.  Please switch to
+using cone mode.
+
 
 INTERNALS -- CONE MODE HANDLING
 -------------------------------
-- 
gitgitgadget
Previous: Elijah Newren via GitGitGadgetNext: Elijah Newren via GitGitGadget
Message 51 of 54 in “sparse-checkout: make cone mode the default”
  1. 0/9 sparse-checkout: make cone mode the defaultElijah Newren via GitGitGadget, Mar 8, 2022
  2. 3/9 git-sparse-checkout.txt: wording updates for the cone mode defaultElijah Newren via GitGitGadget, Mar 8, 2022
  3. 2/9 sparse-checkout: make --cone the defaultElijah Newren via GitGitGadget, Mar 8, 2022
  4. Derrick StoleeMar 8, 2022
  5. Elijah NewrenMar 12, 2022
  6. 1/9 tests: stop assuming --no-cone is the default mode for sparse-checkoutElijah Newren via GitGitGadget, Mar 8, 2022
  7. 4/9 git-sparse-checkout.txt: update docs for deprecation of 'init'Elijah Newren via GitGitGadget, Mar 8, 2022
  8. 5/9 git-sparse-checkout.txt: shuffle some sections and mark as internalElijah Newren via GitGitGadget, Mar 8, 2022
  9. 6/9 git-sparse-checkout.txt: add a new EXAMPLES sectionElijah Newren via GitGitGadget, Mar 8, 2022
  10. Derrick StoleeMar 8, 2022
  11. Elijah NewrenMar 12, 2022
  12. 7/9 git-sparse-checkout.txt: flesh out non-cone mode pattern discussion a bitElijah Newren via GitGitGadget, Mar 8, 2022
  13. 8/9 git-sparse-checkout.txt: mark non-cone mode as deprecatedElijah Newren via GitGitGadget, Mar 8, 2022
  14. 9/9 Documentation: some sparsity wording clarificationsElijah Newren via GitGitGadget, Mar 8, 2022
  15. Derrick StoleeMar 8, 2022
  16. 0/9 sparse-checkout: make cone mode the defaultElijah Newren via GitGitGadget, Mar 12, 2022
  17. 2/9 sparse-checkout: make --cone the defaultElijah Newren via GitGitGadget, Mar 12, 2022
  18. Junio C HamanoMar 14, 2022
  19. Elijah NewrenApr 22, 2022
  20. 1/9 tests: stop assuming --no-cone is the default mode for sparse-checkoutElijah Newren via GitGitGadget, Mar 12, 2022
  21. Junio C HamanoMar 14, 2022
  22. Derrick StoleeMar 15, 2022
  23. 3/9 git-sparse-checkout.txt: wording updates for the cone mode defaultElijah Newren via GitGitGadget, Mar 12, 2022
  24. Junio C HamanoMar 14, 2022
  25. 4/9 git-sparse-checkout.txt: update docs for deprecation of 'init'Elijah Newren via GitGitGadget, Mar 12, 2022
  26. Junio C HamanoMar 14, 2022
  27. Elijah NewrenApr 22, 2022
  28. Junio C HamanoApr 22, 2022
  29. 6/9 git-sparse-checkout.txt: add a new EXAMPLES sectionElijah Newren via GitGitGadget, Mar 12, 2022
  30. 5/9 git-sparse-checkout.txt: shuffle some sections and mark as internalElijah Newren via GitGitGadget, Mar 12, 2022
  31. Junio C HamanoMar 14, 2022
  32. Elijah NewrenApr 22, 2022
  33. 7/9 git-sparse-checkout.txt: flesh out non-cone mode pattern discussion a bitElijah Newren via GitGitGadget, Mar 12, 2022
  34. Junio C HamanoMar 14, 2022
  35. Elijah NewrenApr 22, 2022
  36. 8/9 git-sparse-checkout.txt: mark non-cone mode as deprecatedElijah Newren via GitGitGadget, Mar 12, 2022
  37. Junio C HamanoMar 14, 2022
  38. Elijah NewrenApr 22, 2022
  39. 9/9 Documentation: some sparsity wording clarificationsElijah Newren via GitGitGadget, Mar 12, 2022
  40. Derrick StoleeMar 14, 2022
  41. Victoria DyeMar 14, 2022
  42. Junio C HamanoMar 14, 2022
  43. Junio C HamanoMar 14, 2022
  44. 0/9 sparse-checkout: make cone mode the defaultElijah Newren via GitGitGadget, Apr 22, 2022
  45. 1/9 tests: stop assuming --no-cone is the default mode for sparse-checkoutElijah Newren via GitGitGadget, Apr 22, 2022
  46. 2/9 sparse-checkout: make --cone the defaultElijah Newren via GitGitGadget, Apr 22, 2022
  47. 3/9 git-sparse-checkout.txt: wording updates for the cone mode defaultElijah Newren via GitGitGadget, Apr 22, 2022
  48. 4/9 git-sparse-checkout.txt: update docs for deprecation of 'init'Elijah Newren via GitGitGadget, Apr 22, 2022
  49. 5/9 git-sparse-checkout.txt: shuffle some sections and mark as internalElijah Newren via GitGitGadget, Apr 22, 2022
  50. 9/9 Documentation: some sparsity wording clarificationsElijah Newren via GitGitGadget, Apr 22, 2022
  51. 8/9 git-sparse-checkout.txt: mark non-cone mode as deprecatedElijah Newren via GitGitGadget, Apr 22, 2022
  52. 7/9 git-sparse-checkout.txt: flesh out pattern set sections a bitElijah Newren via GitGitGadget, Apr 22, 2022
  53. 6/9 git-sparse-checkout.txt: add a new EXAMPLES sectionElijah Newren via GitGitGadget, Apr 22, 2022
  54. Derrick StoleeApr 25, 2022

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.