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

Re: [PATCH v3 2/3] sparse-checkout: custom tab completion

From
SZEDER Gábor <szeder.dev@gmail.com>
Date
Jan 18, 2022, 22:22 UTC
Message-ID
<20220118222234.GB2632@szeder.dev>
In-Reply-To
<CABPp-BGR+UrW5ej-8+XXHPkjMfFgURycd9rWC+2awUvYcr_PXA@mail.gmail.com>
On Sat, Jan 15, 2022 at 05:03:24PM -0800, Elijah Newren wrote:
Show 21 quoted lines
> On Sat, Jan 15, 2022 at 1:57 AM SZEDER Gábor <szeder.dev@gmail.com> wrote:
> >
> > On Mon, Jan 10, 2022 at 06:59:51PM +0000, Lessley Dennington via GitGitGadget wrote:
> > > Subject: Re: [PATCH v3 2/3] sparse-checkout: custom tab completion
> >
> > None of these patches touch sparse-checkout, but only the completion
> > script and its tests.  Therefore "completion:" would be a better
> > matching area prefix.
> 
> Thanks for the detailed feedback and guidance in your review.  Very
> helpful.  I'll omit quoting most of it here, but I do want to comment
> on the point about directories.
> 
> ...
> > > 4. A list of directories (but not files) is provided when users enter git
> > > sparse-checkout add <TAB> or git sparse-checkout set <TAB>.
> >
> > Why limit completion only to directories?  Both of those subcommands
> > accept files,
> 
> Discussed in part at [1], but let me give a more detailed answer.

It was a semi-rhetorical question. Whether the reasons for expluding files are sound or not, it should be convincingly justified in the commit message.

Show 30 quoted lines
> Both of these commands accept not only directories and files, but also
> nearly arbitrary input as far as I can tell.  (In cone-mode, it'll
> accept anything so long as it doesn't look like a relative path that
> tries to reach above the toplevel directory with '../' sequences.  In
> non-cone mode, I think it accepts completely arbitrary input).  If our
> guide is merely what the command swallows, then we should forgo
> completion for these subcommands, because it's not possible to
> enumerate all possible completions.  I don't think that's a useful
> guide or starting point, so we instead need to discuss what are
> reasonable completions.
> 
> cone-mode works exclusively on directories.  So, in that mode,
> directories are what we want to complete on.  (And if a file is
> specified, cone-mode will treat it as a directory and add expressions
> for including all the files under that "directory", which might be
> confusing.  sparse-checkout doesn't verify it is a diretory, because
> it *might* name a directory in a different branch, including one not
> yet downloaded.  But "might name a directory on another branch" is no
> reason to suggest picking that pathname with completion.)
> 
> In non-cone mode, arbitrary expressions are valid and will be treated
> as gitignore-style expressions.  That again leaves us with either not
> providing completions, or choosing a subset of possible inputs that
> are reasonable suggestions for users.  I prefer the latter, and in
> particular I feel that directories are reasonable suggestions.  In
> contrast, I don't think providing files is helpful, because it
> reinforces the design flaw of non-cone mode.  Non-cone mode has
> quadratic performance baked into its design, and since
> sparse-checkouts are about performance, non-cone mode kind of defeats
> the purpose of the command.

Or about disk space. Which, because of the potentially significantly reduced number of files in the work tree can bring along significant performance benefits, even with quadratic behavior.

Show 21 quoted lines
>  (In addition to other problems[2].)  So,
> I think non-cone mode should be deprecated and excised.  Patches
> elsewhere are moving in the direction of deprecation already[3], and
> we've already discussed multiple steps we'll likely take soon
> continuing in that direction.  In the meantime, providing just
> directories for completion seems like a good direction to me.
> 
> [1] https://lore.kernel.org/git/CABPp-BG=wr81CPtW1M12xFN_0dyS8mAZjM6o=77LA20Zge8Xng@mail.gmail.com/
> [2] https://lore.kernel.org/git/CABPp-BF=-1aZd=nFHF6spo7Ksa7f7Wb7ervCt0QvtNitMY=ZBA@mail.gmail.com/
> [3] https://lore.kernel.org/git/0af00779128e594aff0ee4ec5378addeac8e88a2.1642175983.git.gitgitgadget@gmail.com/
> ("This mode is harder to use and less performant, and is thus not
> recommended.")
> 
> > and I think 'git sparse-checkout set README.md' is a
> > perfectly reasonable command.
> 
> Reasonable in what sense?  That it makes it (vastly) easier to
> implement the completion and sparse-checkout set|add will swallow it,
> or that it's something that should actually be recommended for users
> doing sparse-checkouts?  While the former certainly holds, I don't
> think the latter does.

I used the following command to create a sparse-checkout from linux.git to build and play with 'perf':

  git sparse-checkout set tools/perf/ tools/scripts/ tools/build/ tools/include/ tools/arch/x86/ tools/lib/ /.gitignore /.gitattributes

Including the top-level '.gitignore' and '.gitattributes' was important, becase those ignore object files and specify userdiff. Now, I wouldn't mind having other files present in the top-level directory, because there are only a handful of files there. However, being able to specify just those two files to 'git sparse-checkout' was great, because I didn't even have to think about what wildcard pattern to use, and what negative pattern to use to exclude anything that might have been included recursively.

I don't remember having any performance issues with it, on the contrary, I do remember that Git suddenly became much faster that in the full worktree.

So I'm fairly convinced that specifying files to sparse-checkout is a feature that can make users' life easier. It certainly made my life easier.

On a related note: I just noticed the leading slashes in '/.gitignore' and '/.gitattributes'. __git_complete_index_file() is not ready for that, I'm afraid; but I don't think the proposed patches could deal with that, either (but I didn't actually try).

It would be great if completion could cope with patterns starting with '/' and/or '!'.

Previous: Lessley DenningtonNext: Elijah Newren
Message 40 of 95 in “sparse checkout: custom bash completion updates”
  1. 0/2 sparse checkout: custom bash completion updatesLessley Dennington via GitGitGadget, Dec 30, 2021
  2. 2/2 sparse-checkout: custom tab completionLessley Dennington via GitGitGadget, Dec 30, 2021
  3. Derrick StoleeDec 30, 2021
  4. Lessley DenningtonDec 30, 2021
  5. 1/2 sparse-checkout: custom tab completion testsLessley Dennington via GitGitGadget, Dec 30, 2021
  6. Derrick StoleeDec 30, 2021
  7. Lessley DenningtonDec 30, 2021
  8. Derrick StoleeDec 30, 2021
  9. Elijah NewrenDec 31, 2021
  10. Lessley DenningtonJan 4, 2022
  11. 0/2 sparse checkout: custom bash completion updatesLessley Dennington via GitGitGadget, Dec 30, 2021
  12. 1/2 sparse-checkout: custom tab completion testsLessley Dennington via GitGitGadget, Dec 30, 2021
  13. Elijah NewrenDec 31, 2021
  14. Junio C HamanoDec 31, 2021
  15. Elijah NewrenDec 31, 2021
  16. Lessley DenningtonJan 4, 2022
  17. Elijah NewrenJan 4, 2022
  18. Lessley DenningtonJan 5, 2022
  19. Lessley DenningtonJan 4, 2022
  20. 2/2 sparse-checkout: custom tab completionLessley Dennington via GitGitGadget, Dec 30, 2021
  21. Elijah NewrenDec 31, 2021
  22. Lessley DenningtonJan 4, 2022
  23. Elijah NewrenJan 4, 2022
  24. Lessley DenningtonJan 5, 2022
  25. Elijah NewrenJan 5, 2022
  26. 0/3 sparse checkout: custom bash completion updatesLessley Dennington via GitGitGadget, Jan 10, 2022
  27. 2/3 sparse-checkout: custom tab completionLessley Dennington via GitGitGadget, Jan 10, 2022
  28. SZEDER GáborJan 15, 2022
  29. Elijah NewrenJan 16, 2022
  30. Junio C HamanoJan 16, 2022
  31. Elijah NewrenJan 17, 2022
  32. Junio C HamanoJan 17, 2022
  33. Lessley DenningtonJan 18, 2022
  34. Lessley DenningtonJan 22, 2022
  35. Lessley DenningtonJan 22, 2022
  36. Lessley DenningtonJan 22, 2022
  37. SZEDER GáborJan 18, 2022
  38. Elijah NewrenJan 18, 2022
  39. Lessley DenningtonJan 18, 2022
  40. SZEDER GáborJan 18, 2022
  41. Elijah NewrenJan 18, 2022
  42. 1/3 sparse-checkout: custom tab completion testsLessley Dennington via GitGitGadget, Jan 10, 2022
  43. 3/3 sparse-checkout: limit tab completion to a single levelLessley Dennington via GitGitGadget, Jan 10, 2022
  44. Lessley DenningtonJan 12, 2022
  45. Junio C HamanoJan 13, 2022
  46. Elijah NewrenJan 13, 2022
  47. Lessley DenningtonJan 13, 2022
  48. Elijah NewrenJan 10, 2022
  49. Lessley DenningtonJan 11, 2022
  50. Taylor BlauJan 11, 2022
  51. Lessley DenningtonJan 12, 2022
  52. 0/3 completion: sparse-checkout updatesLessley Dennington via GitGitGadget, Jan 27, 2022
  53. 1/3 completion: add sparse-checkout testsLessley Dennington via GitGitGadget, Jan 27, 2022
  54. Elijah NewrenJan 28, 2022
  55. Junio C HamanoJan 28, 2022
  56. Elijah NewrenJan 28, 2022
  57. 2/3 completion: sparse-checkout updatesLessley Dennington via GitGitGadget, Jan 27, 2022
  58. Elijah NewrenJan 28, 2022
  59. Lessley DenningtonJan 31, 2022
  60. Elijah NewrenJan 31, 2022
  61. 3/3 completion: ensure cone mode completion with multiple <TAB>sLessley Dennington via GitGitGadget, Jan 27, 2022
  62. Elijah NewrenJan 28, 2022
  63. 0/3 completion: sparse-checkout updatesLessley Dennington via GitGitGadget, Feb 3, 2022
  64. 1/3 completion: address sparse-checkout issuesLessley Dennington via GitGitGadget, Feb 3, 2022
  65. Elijah NewrenFeb 3, 2022
  66. Lessley DenningtonFeb 4, 2022
  67. 2/3 completion: improve sparse-checkout cone mode directory completionLessley Dennington via GitGitGadget, Feb 3, 2022
  68. 3/3 completion: handle unusual characters for sparse-checkoutLessley Dennington via GitGitGadget, Feb 3, 2022
  69. Elijah NewrenFeb 3, 2022
  70. Lessley DenningtonFeb 4, 2022
  71. Ævar Arnfjörð BjarmasonFeb 4, 2022
  72. Junio C HamanoFeb 4, 2022
  73. Junio C HamanoFeb 3, 2022
  74. Lessley DenningtonFeb 3, 2022
  75. Junio C HamanoFeb 3, 2022
  76. Lessley DenningtonFeb 3, 2022
  77. Lessley DenningtonFeb 4, 2022
  78. Lessley DenningtonFeb 4, 2022
  79. Ævar Arnfjörð BjarmasonFeb 4, 2022
  80. 0/3 completion: sparse-checkout updatesLessley Dennington via GitGitGadget, Feb 4, 2022
  81. 1/3 completion: address sparse-checkout issuesLessley Dennington via GitGitGadget, Feb 4, 2022
  82. 2/3 completion: improve sparse-checkout cone mode directory completionLessley Dennington via GitGitGadget, Feb 4, 2022
  83. 3/3 completion: handle unusual characters for sparse-checkoutLessley Dennington via GitGitGadget, Feb 4, 2022
  84. Elijah NewrenFeb 4, 2022
  85. Junio C HamanoFeb 4, 2022
  86. Elijah NewrenFeb 4, 2022
  87. Junio C HamanoFeb 4, 2022
  88. Elijah NewrenFeb 4, 2022
  89. Junio C HamanoFeb 4, 2022
  90. 0/3 completion: sparse-checkout updatesLessley Dennington via GitGitGadget, Feb 7, 2022
  91. 2/3 completion: improve sparse-checkout cone mode directory completionLessley Dennington via GitGitGadget, Feb 7, 2022
  92. 3/3 completion: handle unusual characters for sparse-checkoutLessley Dennington via GitGitGadget, Feb 7, 2022
  93. Adam DinwoodieApr 6, 2022
  94. 1/3 completion: address sparse-checkout issuesLessley Dennington via GitGitGadget, Feb 7, 2022
  95. Elijah NewrenFeb 8, 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.