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

[PATCH v3 00/10] sparse-checkout: make set subsume init

From
Elijah Newren via GitGitGadget <gitgitgadget@gmail.com>
Date
Dec 10, 2021, 03:56 UTC
Message-ID
<pull.1151.v3.git.git.1639108573.gitgitgadget@gmail.com>
In-Reply-To
<pull.1151.v2.git.git.1638908410.gitgitgadget@gmail.com>

As described at [1], the split of init and set subcommands in sparse-checkout causes multiple issues:

 * Poor performance (deleting all tracked files, then later restoring many
   and maybe even most of them)
 * Poor UI (multiple progress bars in wrappers that hide both commands under
   1 user-facing command)
 * Loss of ignored files under directories the user wanted to keep

This series fixes this bug by providing a single command to switch to a sparse-checkout: set. It does so by making set able to do the combined work of init and set. It keeps init as-is to give folks time to adapt, but marks it as deprecated. It also makes reapply able to toggle cone/non-cone mode and sparse-index/non-sparse-index mode.

Changes since v2:
 * Small documentation wording improvement
 * Added Reviewed-by's from Stolee and Victoria
Changes since v1:
 * Inserted new patches 3 & 4 as additional preparatory cleanups
 * Took the new mode-toggling work code in sparse_checkout_set from the
   previous series and moved it into a new function, as a preparatory patch,
   and made it usable by init/set/reapply
 * Also updated reapply to allow mode-toggling
 * Updated the documentation as per above
 * Various other small items from review comments
A quick overview:
 * Patches 1-4: small preparatory refactorings
 * Patch 5: patch adding new function for toggling {cone,sparse-checkout}
   modes
 * Patch 6: the crux of the series; make set able to handle both init and
   set options
 * Patch 7: make reapply also able to do mode toggling
 * Patches 8-9: documentation modifications (Patch 4 is worth reviewing; it
   marks init as deprecated -- are others okay with that?)
 * Patch 10: trivial modification of git clone --sparse to use git
   sparse-checkout set rather than git sparse-checkout init.

[1] https://lore.kernel.org/git/CABPp-BE8TJ8QGAQWsSGT7S+9Xp-XmApcC9PSw3K=RQOP0rt+PQ@mail.gmail.com/

Elijah Newren (10):
  sparse-checkout: pass use_stdin as a parameter instead of as a global
  sparse-checkout: break apart functions for sparse_checkout_(set|add)
  sparse-checkout: add sanity-checks on initial sparsity state
  sparse-checkout: disallow --no-stdin as an argument to set
  sparse-checkout: split out code for tweaking settings config
  sparse-checkout: enable `set` to initialize sparse-checkout mode
  sparse-checkout: enable reapply to take --[no-]{cone,sparse-index}
  git-sparse-checkout.txt: update to document init/set/reapply changes
  Documentation: clarify/correct a few sparsity related statements
  clone: avoid using deprecated `sparse-checkout init`
 Documentation/git-clone.txt           |   8 +-
 Documentation/git-sparse-checkout.txt | 100 +++++++------
 builtin/clone.c                       |   2 +-
 builtin/sparse-checkout.c             | 196 ++++++++++++++++++++------
 t/t1091-sparse-checkout-builtin.sh    |  10 +-
 5 files changed, 219 insertions(+), 97 deletions(-)
base-commit: abe6bb3905392d5eb6b01fa6e54d7e784e0522aa
Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-1151%2Fnewren%2Fsparse-checkout-no-init-v3
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-1151/newren/sparse-checkout-no-init-v3
Pull-Request: https://github.com/git/git/pull/1151
Range-diff vs v2:
  1:  e41cfe3c1bb !  1:  814aed2d125 sparse-checkout: pass use_stdin as a parameter instead of as a global
     @@ Commit message
          incorrect.  Pass the value as function parameter instead to allow us to
          make subsequent changes.
      
     +    Reviewed-by: Derrick Stolee <dstolee@microsoft.com>
     +    Reviewed-by: Victoria Dye <vdye@github.com>
          Signed-off-by: Elijah Newren <newren@gmail.com>
      
       ## builtin/sparse-checkout.c ##
  2:  6f7de8f5412 !  2:  04cd57592e9 sparse-checkout: break apart functions for sparse_checkout_(set|add)
     @@ Commit message
          function.  This does not introduce any behavioral changes; that will
          come in a subsequent patch.
      
     +    Reviewed-by: Derrick Stolee <dstolee@microsoft.com>
     +    Reviewed-by: Victoria Dye <vdye@github.com>
          Signed-off-by: Elijah Newren <newren@gmail.com>
      
       ## builtin/sparse-checkout.c ##
  3:  bade5e52390 !  3:  f3af5edb25d sparse-checkout: add sanity-checks on initial sparsity state
     @@ Commit message
          only make sense when already in a sparse state.  Add a quick check
          that will error out early if this is not the case.
      
     +    Reviewed-by: Derrick Stolee <dstolee@microsoft.com>
     +    Reviewed-by: Victoria Dye <vdye@github.com>
          Signed-off-by: Elijah Newren <newren@gmail.com>
      
       ## builtin/sparse-checkout.c ##
  4:  0180bfc4a93 !  4:  82a13cc0197 sparse-checkout: disallow --no-stdin as an argument to set
     @@ Commit message
          but didn't intend for --no-stdin to be permitted as well.
      
          Reported-by: Victoria Dye <vdye@github.com>
     +    Reviewed-by: Derrick Stolee <dstolee@microsoft.com>
     +    Reviewed-by: Victoria Dye <vdye@github.com>
          Signed-off-by: Elijah Newren <newren@gmail.com>
      
       ## builtin/sparse-checkout.c ##
  5:  3f5255eeef9 !  5:  7a812e0222c sparse-checkout: split out code for tweaking settings config
     @@ Commit message
          and make it slightly more general so it can handle being called from
          the new callers.
      
     +    Reviewed-by: Derrick Stolee <dstolee@microsoft.com>
     +    Reviewed-by: Victoria Dye <vdye@github.com>
          Signed-off-by: Elijah Newren <newren@gmail.com>
      
       ## builtin/sparse-checkout.c ##
  6:  3c640f5bcef !  6:  7167a4b3118 sparse-checkout: enable `set` to initialize sparse-checkout mode
     @@ Commit message
          parameters that `init` takes and performing any necessary initialization
          if not already in a sparse checkout.
      
     +    Reviewed-by: Derrick Stolee <dstolee@microsoft.com>
     +    Reviewed-by: Victoria Dye <vdye@github.com>
          Signed-off-by: Elijah Newren <newren@gmail.com>
      
       ## builtin/sparse-checkout.c ##
  7:  acb10889a1f !  7:  3687637915f sparse-checkout: enable reapply to take --[no-]{cone,sparse-index}
     @@ Commit message
          sparse-index without changing their sparsity paths.  Allow them to do so
          using the reapply command.
      
     +    Reviewed-by: Derrick Stolee <dstolee@microsoft.com>
     +    Reviewed-by: Victoria Dye <vdye@github.com>
          Signed-off-by: Elijah Newren <newren@gmail.com>
      
       ## builtin/sparse-checkout.c ##
  8:  17b033caf4b !  8:  7483d1363e5 git-sparse-checkout.txt: update to document init/set/reapply changes
     @@ Commit message
          to tweak the {cone,sparse-index} settings.  Update the documentation to
          reflect this, and mark `init` as deprecated.
      
     +    Reviewed-by: Derrick Stolee <dstolee@microsoft.com>
     +    Reviewed-by: Victoria Dye <vdye@github.com>
          Signed-off-by: Elijah Newren <newren@gmail.com>
      
       ## Documentation/git-sparse-checkout.txt ##
     @@ Documentation/git-sparse-checkout.txt: C-style quoted strings.
      +	Deprecated command that behaves like `set` with no specified paths.
      +	May be removed in the future.
      ++
     -+Historically, `set` did not used to handle all the necessary config
     -+settings, which meant that both `init` and `set` had to be called.
     -+Invoking both meant the `init` step would first remove nearly all
     -+tracked files (and in cone mode, ignored files too), then the `set`
     -+step would add many of the tracked files (but not ignored files) back.
     -+In addition to the lost files, the performance and UI of this
     -+combination was poor.
     ++Historically, `set` did not handle all the necessary config settings,
     ++which meant that both `init` and `set` had to be called.  Invoking
     ++both meant the `init` step would first remove nearly all tracked files
     ++(and in cone mode, ignored files too), then the `set` step would add
     ++many of the tracked files (but not ignored files) back.  In addition
     ++to the lost files, the performance and UI of this combination was
     ++poor.
      ++
      +Also, historically, `init` would not actually initialize the
      +sparse-checkout file if it already existed.  This meant it was
  9:  922a65b4019 !  9:  11a45920602 Documentation: clarify/correct a few sparsity related statements
     @@ Metadata
       ## Commit message ##
          Documentation: clarify/correct a few sparsity related statements
      
     +    Reviewed-by: Derrick Stolee <dstolee@microsoft.com>
     +    Reviewed-by: Victoria Dye <vdye@github.com>
          Signed-off-by: Elijah Newren <newren@gmail.com>
      
       ## Documentation/git-clone.txt ##
 10:  d47b2c88242 ! 10:  395d9b194d3 clone: avoid using deprecated `sparse-checkout init`
     @@ Commit message
          The previous commits marked `sparse-checkout init` as deprecated; we
          can just use `set` instead here and pass it no paths.
      
     +    Reviewed-by: Derrick Stolee <dstolee@microsoft.com>
     +    Reviewed-by: Victoria Dye <vdye@github.com>
          Signed-off-by: Elijah Newren <newren@gmail.com>
      
       ## builtin/clone.c ##
-- 
gitgitgadget
Previous: Victoria DyeNext: Elijah Newren via GitGitGadget
Message 33 of 63 in “sparse-checkout: make set subsume init”
  1. 0/6 sparse-checkout: make set subsume initElijah Newren via GitGitGadget, Dec 4, 2021
  2. 1/6 sparse-checkout: pass use_stdin as a parameter instead of as a globalElijah Newren via GitGitGadget, Dec 4, 2021
  3. 2/6 sparse-checkout: break apart functions for sparse_checkout_(set|add)Elijah Newren via GitGitGadget, Dec 4, 2021
  4. 3/6 sparse-checkout: enable `set` to initialize sparse-checkout modeElijah Newren via GitGitGadget, Dec 4, 2021
  5. Victoria DyeDec 4, 2021
  6. Elijah NewrenDec 7, 2021
  7. Lessley DenningtonDec 7, 2021
  8. Derrick StoleeDec 7, 2021
  9. Elijah NewrenDec 7, 2021
  10. 4/6 git-sparse-checkout.txt: update to document that set handles initElijah Newren via GitGitGadget, Dec 4, 2021
  11. Victoria DyeDec 4, 2021
  12. Derrick StoleeDec 7, 2021
  13. Elijah NewrenDec 7, 2021
  14. Lessley DenningtonDec 7, 2021
  15. Elijah NewrenDec 7, 2021
  16. Lessley DenningtonDec 7, 2021
  17. 5/6 Documentation: clarify/correct a few sparsity related statementsElijah Newren via GitGitGadget, Dec 4, 2021
  18. 6/6 clone: avoid using deprecated `sparse-checkout init`Elijah Newren via GitGitGadget, Dec 4, 2021
  19. Derrick StoleeDec 7, 2021
  20. 00/10 sparse-checkout: make set subsume initElijah Newren via GitGitGadget, Dec 7, 2021
  21. 01/10 sparse-checkout: pass use_stdin as a parameter instead of as a globalElijah Newren via GitGitGadget, Dec 7, 2021
  22. 02/10 sparse-checkout: break apart functions for sparse_checkout_(set|add)Elijah Newren via GitGitGadget, Dec 7, 2021
  23. 03/10 sparse-checkout: add sanity-checks on initial sparsity stateElijah Newren via GitGitGadget, Dec 7, 2021
  24. 04/10 sparse-checkout: disallow --no-stdin as an argument to setElijah Newren via GitGitGadget, Dec 7, 2021
  25. 05/10 sparse-checkout: split out code for tweaking settings configElijah Newren via GitGitGadget, Dec 7, 2021
  26. 06/10 sparse-checkout: enable `set` to initialize sparse-checkout modeElijah Newren via GitGitGadget, Dec 7, 2021
  27. 07/10 sparse-checkout: enable reapply to take --[no-]{cone,sparse-index}Elijah Newren via GitGitGadget, Dec 7, 2021
  28. 08/10 git-sparse-checkout.txt: update to document init/set/reapply changesElijah Newren via GitGitGadget, Dec 7, 2021
  29. 09/10 Documentation: clarify/correct a few sparsity related statementsElijah Newren via GitGitGadget, Dec 7, 2021
  30. 10/10 clone: avoid using deprecated `sparse-checkout init`Elijah Newren via GitGitGadget, Dec 7, 2021
  31. Derrick StoleeDec 7, 2021
  32. Victoria DyeDec 8, 2021
  33. 00/10 sparse-checkout: make set subsume initElijah Newren via GitGitGadget, Dec 10, 2021
  34. 01/10 sparse-checkout: pass use_stdin as a parameter instead of as a globalElijah Newren via GitGitGadget, Dec 10, 2021
  35. 02/10 sparse-checkout: break apart functions for sparse_checkout_(set|add)Elijah Newren via GitGitGadget, Dec 10, 2021
  36. 03/10 sparse-checkout: add sanity-checks on initial sparsity stateElijah Newren via GitGitGadget, Dec 10, 2021
  37. Junio C HamanoDec 13, 2021
  38. Elijah NewrenDec 14, 2021
  39. 04/10 sparse-checkout: disallow --no-stdin as an argument to setElijah Newren via GitGitGadget, Dec 10, 2021
  40. 06/10 sparse-checkout: enable `set` to initialize sparse-checkout modeElijah Newren via GitGitGadget, Dec 10, 2021
  41. 05/10 sparse-checkout: split out code for tweaking settings configElijah Newren via GitGitGadget, Dec 10, 2021
  42. 07/10 sparse-checkout: enable reapply to take --[no-]{cone,sparse-index}Elijah Newren via GitGitGadget, Dec 10, 2021
  43. Junio C HamanoDec 13, 2021
  44. Elijah NewrenDec 14, 2021
  45. 08/10 git-sparse-checkout.txt: update to document init/set/reapply changesElijah Newren via GitGitGadget, Dec 10, 2021
  46. 09/10 Documentation: clarify/correct a few sparsity related statementsElijah Newren via GitGitGadget, Dec 10, 2021
  47. 10/10 clone: avoid using deprecated `sparse-checkout init`Elijah Newren via GitGitGadget, Dec 10, 2021
  48. 00/10 sparse-checkout: make set subsume initElijah Newren via GitGitGadget, Dec 14, 2021
  49. 01/10 sparse-checkout: pass use_stdin as a parameter instead of as a globalElijah Newren via GitGitGadget, Dec 14, 2021
  50. 02/10 sparse-checkout: break apart functions for sparse_checkout_(set|add)Elijah Newren via GitGitGadget, Dec 14, 2021
  51. 03/10 sparse-checkout: add sanity-checks on initial sparsity stateElijah Newren via GitGitGadget, Dec 14, 2021
  52. 04/10 sparse-checkout: disallow --no-stdin as an argument to setElijah Newren via GitGitGadget, Dec 14, 2021
  53. 05/10 sparse-checkout: split out code for tweaking settings configElijah Newren via GitGitGadget, Dec 14, 2021
  54. 07/10 sparse-checkout: enable reapply to take --[no-]{cone,sparse-index}Elijah Newren via GitGitGadget, Dec 14, 2021
  55. Jiang XinDec 23, 2021
  56. Elijah NewrenDec 23, 2021
  57. Junio C HamanoDec 23, 2021
  58. 09/10 Documentation: clarify/correct a few sparsity related statementsElijah Newren via GitGitGadget, Dec 14, 2021
  59. Bagas SanjayaDec 14, 2021
  60. Elijah NewrenDec 14, 2021
  61. 08/10 git-sparse-checkout.txt: update to document init/set/reapply changesElijah Newren via GitGitGadget, Dec 14, 2021
  62. 06/10 sparse-checkout: enable `set` to initialize sparse-checkout modeElijah Newren via GitGitGadget, Dec 14, 2021
  63. 10/10 clone: avoid using deprecated `sparse-checkout init`Elijah Newren via GitGitGadget, Dec 14, 2021

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.