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

Re: [PATCH 7/7] sparse-checkout: make --cone the default and deprecate --no-cone

From
Derrick Stolee <derrickstolee@github.com>
Date
Feb 14, 2022, 16:14 UTC
Message-ID
<d9bdf8c0-a449-ef12-fa80-5976ea9bd6c4@github.com>
In-Reply-To
<e30119b96dfaf9fdb82039cab84f8b81caacc1de.1644712798.git.gitgitgadget@gmail.com>
On 2/12/2022 7:39 PM, Elijah Newren via GitGitGadget wrote:
Show 7 quoted lines
> From: Elijah Newren <newren@gmail.com>
> 
> Make --cone mode the default, and deprecate --no-cone mode.  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.

"deprecate" is a good word here. The functionality remains, but we make clear recommendations to not use it.

Show 6 quoted lines
> While at it, since the new default just uses directories and removes the
> need to understand patterns, we can mark multiple sections in the manual
> as "INTERNALS" to reflect the fact that users do not need to wade
> through those sections to understand how to use the command any more.
> We can instead add a simple EXAMPLES section to the manual which
> distills the necessary bits from the more complex INTERNALS sections.
Show 9 quoted lines
> -SPARSE CHECKOUT
> ----------------
> +EXAMPLES
> +--------
> +`git sparse-checkout set MY/DIR1 SUB/DIR2`::
> +
> +	Change to a sparse-checkout with all files (at any depth) under
> +	MY/DIR1/ and SUB/DIR2/ present in the working copy (plus all
> +	files immediately under MY/ and SUB/ and the toplevel
Do we like "toplevel" or "top-level"?
> +	directory).  If already in a sparse checkout, change which files

There is some inconsistency between "a sparse checkout" and "a sparse-checkout" here. I'm happy with either as long as we stay consistent.

Show 30 quoted lines
> +	are present in the working copy to this new selection.  Note
> +	that this command will also delete all ignored files in any
> +	directory that no longer has either tracked or
> +	non-ignored-untracked files present.
> +
> +`git sparse-checkout disable`::
> +
> +	Repopulate the working directory with all files, disabling sparse
> +	checkouts.
> +
> +`git sparse-checkout add SOME/DIR/ECTORY`::
> +
> +	Add all files under SOME/DIR/ECTORY/ (at any depth) to the
> +	sparse checkout, as well as all files immediately under
> +	SOME/DIR/ and immediately under SOME/.  Must already be in a
> +	sparse checkout before using this command.
> +
> +`git sparse-checkout reapply`::
> +
> +	It is possible for commands to update the working tree in a way
> +	that does not respect the selected sparsity directories, either
> +	because of special cases (such as hitting conflicts when
> +	merging/rebasing), or because some commands didn't fully support
> +	sparse checkouts (e.g. the old `recursive` merge backend had
> +	only limited support).  This command reapplies the existing
> +	sparse directory specifications to make the working directory
> +	match.
> +
> +INTERNALS -- SPARSE CHECKOUT
> +----------------------------
I like this switch to talk about "internals".
Show 10 quoted lines
> +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:
...
> +For all these reasons, non-cone mode is deprecated.  Please switch to
> +using cone mode.

I appreciate your very clear description here, as it helps make the case for us.

Show 13 quoted lines
> +INTERNALS -- FULL PATTERN SET
> +-----------------------------
> +
> +As noted above, the sparse-checkout file uses the same syntax as
> +`.gitignore` files; see linkgit:gitignore[5] for details.  Here, though,
> +the patterns are being used to select which files to include rather than
> +which files to exclude.
> +
> +To complicate things a bit further, while
> +`$GIT_DIR/info/sparse-checkout` is usually used to specify what files
> +are included, you can also specify what files are _not_ included, using
> +negative patterns. For example, to select everything, and then to remove
> +the file `unwanted`:
...
> -----------------
> +INTERNALS -- CONE PATTERN SET
> +-----------------------------

I wonder if this should be moved further up, above of the non-cone internals.

Show 8 quoted lines
> -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.sparseCheckoutCone` is enabled.
> +The full pattern set allows for arbitrary pattern matches and
> +complicated inclusion/exclusion rules. As noted above, this can result
> +in O(N*M) pattern matches when updating the index, where N is the number
I see you are including information about O(N*M) "as noted above". I think
the cone pattern set should shift to assume it's the first mode people read,
and then the comparisons can happen in the non-cone mode internals.
 
Show 22 quoted lines
>  If your repository contains one or more submodules, then submodules
>  are populated based on interactions with the `git submodule` command.
> diff --git a/builtin/sparse-checkout.c b/builtin/sparse-checkout.c
> index 6e0af166f80..aa2c66f15e3 100644
> --- a/builtin/sparse-checkout.c
> +++ b/builtin/sparse-checkout.c
> @@ -395,13 +395,13 @@ static int update_modes(int *cone_mode, int *sparse_index)
>  
>  	/* Set cone/non-cone mode appropriately */
>  	core_apply_sparse_checkout = 1;
> -	if (*cone_mode == 1) {
> +	if (*cone_mode == 1 || *cone_mode == -1) {
>  		mode = MODE_CONE_PATTERNS;
> -		core_sparse_checkout_cone = 1;
> +		if (record_mode)
> +			core_sparse_checkout_cone = 1;
>  	} else {
>  		mode = MODE_ALL_PATTERNS;
> -		if (record_mode)
> -			core_sparse_checkout_cone = 0;
> +		core_sparse_checkout_cone = 0;
>  	}

Ok, this "record_mode" is showing up again here, so I assume it is important and based on whatever is the default.

You are right that this commit is big. I think there are a few ways to split it up to be easier to review:

1. Make test changes to insert "--no-cone" wherever needed.
2. Make default switch in code and change docs only to say which is
   the default.
3. Rename the sections of the document and move their current
   contents.
4. Update the non-cone docs with the reasons for its deprecation.

I also think that you've got two full _series_ on your hands. The patches 1-6 are likely easier to review quickly and get merged while we leave this deprecation series (this patch, split up as you see fit) up for discussion.

I am in support of this idea, and I will make that case on your cover letter.

Thanks, -Stolee

Previous: Elijah Newren via GitGitGadgetNext: Elijah Newren
Message 22 of 70 in “RFC: sparse checkout: make --cone mode the default, and check add/set argument validity”
  1. 0/7 RFC: sparse checkout: make --cone mode the default, and check add/set argument validityElijah Newren via GitGitGadget, Feb 13, 2022
  2. 1/7 sparse-checkout: correct reapply's handling of optionsElijah Newren via GitGitGadget, Feb 13, 2022
  3. 3/7 sparse-checkout: pay attention to prefix for {set, add}Elijah Newren via GitGitGadget, Feb 13, 2022
  4. Derrick StoleeFeb 14, 2022
  5. Elijah NewrenFeb 15, 2022
  6. Derrick StoleeFeb 15, 2022
  7. 2/7 sparse-checkout: correctly set non-cone mode when expectedElijah Newren via GitGitGadget, Feb 13, 2022
  8. Derrick StoleeFeb 14, 2022
  9. Elijah NewrenFeb 15, 2022
  10. 4/7 sparse-checkout: error or warn when given individual filesElijah Newren via GitGitGadget, Feb 13, 2022
  11. Derrick StoleeFeb 14, 2022
  12. Elijah NewrenFeb 15, 2022
  13. Derrick StoleeFeb 15, 2022
  14. 6/7 sparse-checkout: reject arguments in cone-mode that look like patternsElijah Newren via GitGitGadget, Feb 13, 2022
  15. 5/7 sparse-checkout: reject non-cone-mode patterns starting with a '#'Elijah Newren via GitGitGadget, Feb 13, 2022
  16. Junio C HamanoFeb 14, 2022
  17. Elijah NewrenFeb 15, 2022
  18. Junio C HamanoFeb 16, 2022
  19. Elijah NewrenFeb 16, 2022
  20. Junio C HamanoFeb 16, 2022
  21. 7/7 sparse-checkout: make --cone the default and deprecate --no-coneElijah Newren via GitGitGadget, Feb 13, 2022
  22. Derrick StoleeFeb 14, 2022
  23. Elijah NewrenFeb 15, 2022
  24. Derrick StoleeFeb 14, 2022
  25. Elijah NewrenFeb 15, 2022
  26. Derrick StoleeFeb 15, 2022
  27. 0/6 sparse checkout: fix a few bugs and check argument validity for set/addElijah Newren via GitGitGadget, Feb 15, 2022
  28. 1/6 sparse-checkout: correct reapply's handling of optionsElijah Newren via GitGitGadget, Feb 15, 2022
  29. 2/6 sparse-checkout: correctly set non-cone mode when expectedElijah Newren via GitGitGadget, Feb 15, 2022
  30. 3/6 sparse-checkout: pay attention to prefix for {set, add}Elijah Newren via GitGitGadget, Feb 15, 2022
  31. Ævar Arnfjörð BjarmasonFeb 17, 2022
  32. Elijah NewrenFeb 18, 2022
  33. 4/6 sparse-checkout: error or warn when given individual filesElijah Newren via GitGitGadget, Feb 15, 2022
  34. Ævar Arnfjörð BjarmasonFeb 17, 2022
  35. 5/6 sparse-checkout: reject non-cone-mode patterns starting with a '#'Elijah Newren via GitGitGadget, Feb 15, 2022
  36. 6/6 sparse-checkout: reject arguments in cone-mode that look like patternsElijah Newren via GitGitGadget, Feb 15, 2022
  37. Derrick StoleeFeb 15, 2022
  38. 0/5 sparse checkout: fix a few bugs and check argument validity for set/addElijah Newren via GitGitGadget, Feb 16, 2022
  39. 2/5 sparse-checkout: correctly set non-cone mode when expectedElijah Newren via GitGitGadget, Feb 16, 2022
  40. 1/5 sparse-checkout: correct reapply's handling of optionsElijah Newren via GitGitGadget, Feb 16, 2022
  41. 3/5 sparse-checkout: pay attention to prefix for {set, add}Elijah Newren via GitGitGadget, Feb 16, 2022
  42. 4/5 sparse-checkout: error or warn when given individual filesElijah Newren via GitGitGadget, Feb 16, 2022
  43. 5/5 sparse-checkout: reject arguments in cone-mode that look like patternsElijah Newren via GitGitGadget, Feb 16, 2022
  44. Ævar Arnfjörð BjarmasonFeb 16, 2022
  45. Elijah NewrenFeb 16, 2022
  46. Victoria DyeFeb 16, 2022
  47. Junio C HamanoFeb 16, 2022
  48. Elijah NewrenFeb 17, 2022
  49. Junio C HamanoFeb 17, 2022
  50. Elijah NewrenFeb 17, 2022
  51. Elijah NewrenFeb 17, 2022
  52. Junio C HamanoFeb 16, 2022
  53. 0/5 sparse checkout: fix a few bugs and check argument validity for set/addElijah Newren via GitGitGadget, Feb 17, 2022
  54. 1/5 sparse-checkout: correct reapply's handling of optionsElijah Newren via GitGitGadget, Feb 17, 2022
  55. 2/5 sparse-checkout: correctly set non-cone mode when expectedElijah Newren via GitGitGadget, Feb 17, 2022
  56. 3/5 sparse-checkout: pay attention to prefix for {set, add}Elijah Newren via GitGitGadget, Feb 17, 2022
  57. Junio C HamanoFeb 17, 2022
  58. 5/5 sparse-checkout: reject arguments in cone-mode that look like patternsElijah Newren via GitGitGadget, Feb 17, 2022
  59. 4/5 sparse-checkout: error or warn when given individual filesElijah Newren via GitGitGadget, Feb 17, 2022
  60. Junio C HamanoFeb 17, 2022
  61. Elijah NewrenFeb 18, 2022
  62. Ævar Arnfjörð BjarmasonFeb 17, 2022
  63. 0/5 sparse checkout: fix a few bugs and check argument validity for set/addElijah Newren via GitGitGadget, Feb 19, 2022
  64. 1/5 sparse-checkout: correct reapply's handling of optionsElijah Newren via GitGitGadget, Feb 19, 2022
  65. 2/5 sparse-checkout: correctly set non-cone mode when expectedElijah Newren via GitGitGadget, Feb 19, 2022
  66. 3/5 sparse-checkout: pay attention to prefix for {set, add}Elijah Newren via GitGitGadget, Feb 19, 2022
  67. 4/5 sparse-checkout: error or warn when given individual filesElijah Newren via GitGitGadget, Feb 19, 2022
  68. 5/5 sparse-checkout: reject arguments in cone-mode that look like patternsElijah Newren via GitGitGadget, Feb 19, 2022
  69. Derrick StoleeFeb 20, 2022
  70. Junio C HamanoFeb 20, 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.